Call Assert.AreEqual (expected, expected) should not be interrupted. If you made a mistake in your question, and you meant Assert.AreEqual (expected, actual) , and your HomeControllerHelper.GetNavigationMenuByUserRole returns a new instance of NavigationMenu, then calling Assert.AreEqual always fails, your NavigationMenu type is called - this is the class and, therefore, a reference type, even if you set the properties of instances with the same values.
Assert.AreEqual performs equality checking if two variables point to the same link (aka. ReferenceEqual), and not if two links contain the same (property) value.
You can override the Equals method of your NavigationMenu class to provide a custom implementation if two instances of your class are equal.
Jehof
source share