The entity logical name account is not valid. #534
-
Hello, I am new to Unit Tests and Microsoft CRM Plugin unit testing and I have been having this issue with some of my tests. No matter what I try, it always fails in the same point with the same error message: "The entity logical name account is not valid." If anyone could help me solve this or point me in the right direction, it would be great. Below is my code Plugin Interface
Business Logic
Unit Test
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hello @goncalomelo8, |
Beta Was this translation helpful? Give feedback.
-
Hi @goncalomelo8, I think the problem is that you haven't initialised the context so it doesn't 'know' what an 'account' is. Take a look at this issue #406 - this will show you how to initialise the context so that the record you are retrieving in your test will exist and the context will know what an account is. |
Beta Was this translation helpful? Give feedback.
-
@BetimBeja beat me to it! |
Beta Was this translation helpful? Give feedback.
Hello @goncalomelo8,
in your unit test you are not actually creating the account, you are just testing your plugin with the default context which is PreOperation of Create. Also I guess your test is failing in the Update account request in your CreateRelatedContact class... because the account is not currently in the context. Adding it to the context and testing the plugin should make your test pass, even though, I don't think is the correct way to do your test.