Skip to content

The second call to WithViewData throws NullReferenceException #40

@milichev

Description

@milichev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions