4

I'm working up some unit tests and unsure why this particular test is failing.

The test is to assert that a custom view engine looks in the correct place for views.

In my custom view engine is this:

AreaMasterLocationFormats = new[]
{
    "~/Areas/{2}/App/{1}/Views/{0}.cshtml",
    "~/Areas/{2}/App/Shared/Views/{0}.cshtml"
};

And in my test is this:

string[] expected = new[]
{
    "~/Areas/{2}/App/{1}/Views/{0}.cshtml",
    "~/Areas/{2}/App/Shared/Views/{0}.cshtml"
};

CustomRazorViewEngine engine = new CustomRazorViewEngine();

Assert.AreEqual(expected, engine.AreaMasterLocationFormats);

The test fails with the message:

Message: Assert.AreEqual failed. Expected:<System.String[]>. Actual:<System.String[]>.

(s/o's quote format doesn't like the second lt in that...)

I'm unsure why, as when I debug the test all appears well.

3
  • Not sure why you deleted your answer (whoever you were), but it was correct... Commented May 29, 2016 at 17:21
  • For a moment, I wasn't sure string[] is actually a Collection. Commented May 29, 2016 at 17:23
  • @haim770 Apparently, seeing as how the test passes now :) I'll except when my timer's up, thanks. Commented May 29, 2016 at 17:24

1 Answer 1

6

You need to use CollectionAssert instead:

CollectionAssert.AreEqual(expected, engine.AreaMasterLocationFormats);

See MSDN

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.