public void CreateLetterHead_WhenCalledWithoutModel_ReturnsViewResult() { Controller sut = CreateSut(); IActionResult result = sut.CreateLetterHead(); Assert.That(result, Is.TypeOf <ViewResult>()); }
public void CreateLetterHead_WhenCalledWithoutModel_ReturnsViewResultWhereViewNameIsEqualToCreateLetterHead() { Controller sut = CreateSut(); ViewResult result = (ViewResult)sut.CreateLetterHead(); Assert.That(result.ViewName, Is.EqualTo("CreateLetterHead")); }
public async Task CreateLetterHead_WhenCalledWithInvalidModel_AssertPublishAsyncWasNotCalledOnCommandBus() { Controller sut = CreateSut(false); LetterHeadViewModel model = CreateModel(); await sut.CreateLetterHead(model); _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <ICreateLetterHeadCommand>()), Times.Never); }
public async Task CreateLetterHead_WhenCalledWithValidModel_ReturnsRedirectToActionResultWhereActionNameIsEqualToLetterHeads() { Controller sut = CreateSut(); LetterHeadViewModel model = CreateModel(); RedirectToActionResult result = (RedirectToActionResult)await sut.CreateLetterHead(model); Assert.That(result.ActionName, Is.EqualTo("LetterHeads")); }
public async Task CreateLetterHead_WhenCalledWithValidModel_ReturnsRedirectToActionResult() { Controller sut = CreateSut(); LetterHeadViewModel model = CreateModel(); IActionResult result = await sut.CreateLetterHead(model); Assert.That(result, Is.TypeOf <RedirectToActionResult>()); }
public async Task CreateLetterHead_WhenCalledWithInvalidModel_ReturnsViewResultWhereViewNameIsEqualToCreateLetterHead() { Controller sut = CreateSut(false); LetterHeadViewModel model = CreateModel(); ViewResult result = (ViewResult)await sut.CreateLetterHead(model); Assert.That(result.ViewName, Is.EqualTo("CreateLetterHead")); }
public async Task CreateLetterHead_WhenCalledWithInvalidModel_ReturnsViewResultWhereModelIsEqualToInvalidModel() { Controller sut = CreateSut(false); LetterHeadViewModel model = CreateModel(); ViewResult result = (ViewResult)await sut.CreateLetterHead(model); Assert.That(result.Model, Is.TypeOf <LetterHeadViewModel>()); LetterHeadViewModel letterHeadViewModel = (LetterHeadViewModel)result.Model; Assert.That(letterHeadViewModel, Is.EqualTo(model)); }
public async Task CreateLetterHead_WhenCalledWithValidModel_AssertPublishAsyncWasCalledOnCommandBus() { Controller sut = CreateSut(); LetterHeadViewModel model = CreateModel(); await sut.CreateLetterHead(model); _commandBusMock.Verify(m => m.PublishAsync(It.Is <ICreateLetterHeadCommand>(command => command.Number == model.Number && string.CompareOrdinal(command.Name, model.Name) == 0 && string.CompareOrdinal(command.Line1, model.Line1) == 0 && string.CompareOrdinal(command.Line2, model.Line2) == 0 && string.CompareOrdinal(command.Line3, model.Line3) == 0 && string.CompareOrdinal(command.Line4, model.Line4) == 0 && string.CompareOrdinal(command.Line5, model.Line5) == 0 && string.CompareOrdinal(command.Line6, model.Line6) == 0 && string.CompareOrdinal(command.Line7, model.Line7) == 0 && string.CompareOrdinal(command.CompanyIdentificationNumber, model.CompanyIdentificationNumber) == 0)), Times.Once); }
public void CreateLetterHead_WhenCalledWithoutModel_ReturnsViewResultWhereModelIsLetterHeadViewModel() { Controller sut = CreateSut(); ViewResult result = (ViewResult)sut.CreateLetterHead(); Assert.That(result.Model, Is.TypeOf <LetterHeadViewModel>()); LetterHeadViewModel letterHeadViewModel = (LetterHeadViewModel)result.Model; Assert.That(letterHeadViewModel, Is.Not.Null); Assert.That(letterHeadViewModel.Number, Is.EqualTo(default(int))); Assert.That(letterHeadViewModel.Name, Is.Null); Assert.That(letterHeadViewModel.Line1, Is.Null); Assert.That(letterHeadViewModel.Line2, Is.Null); Assert.That(letterHeadViewModel.Line3, Is.Null); Assert.That(letterHeadViewModel.Line4, Is.Null); Assert.That(letterHeadViewModel.Line5, Is.Null); Assert.That(letterHeadViewModel.Line6, Is.Null); Assert.That(letterHeadViewModel.Line7, Is.Null); Assert.That(letterHeadViewModel.CompanyIdentificationNumber, Is.Null); Assert.That(letterHeadViewModel.EditMode, Is.EqualTo(EditMode.Create)); }
public void CreateLetterHead_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException() { Controller sut = CreateSut(); ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.CreateLetterHead(null)); Assert.That(result.ParamName, Is.EqualTo("letterHeadViewModel")); }