fluentassertions.mvc icon indicating copy to clipboard operation
fluentassertions.mvc copied to clipboard

The second call to WithViewData throws NullReferenceException

Open milichev opened this issue 5 years ago • 1 comments

This code:

            const string pageName = "pageName";

            _sut.GetByPageName(pageName)
                .Should()
                .BeViewResult()
                .WithViewData("PageName", pageName)
                .WithViewData("Roles", _roles) // this call fails!
                .WithViewData("FieldName", null);

causes:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=FluentAssertions.Mvc5
  StackTrace:
   at FluentAssertions.Mvc.ViewResultBaseAssertions`1.WithViewData(String key, Object expectedValue, String reason, Object[] reasonArgs)
   at Tests.Controllers.HelpEditor.HelpEditorControllerTest.GetByPageName_Should_return_view_for_specified_pageName() in ...\....Tests\Controllers\HelpEditor\HelpEditorControllerTest.cs:line 48

milichev avatar Jun 21 '20 12:06 milichev

@milichev if you're able to fix, I would gladly take a PR.

kevinkuszyk avatar Jun 25 '20 09:06 kevinkuszyk