public async Task UpdateCountry_WhenCalledWithCode_ReturnsViewResult() { Controller sut = CreateSut(); IActionResult result = await sut.UpdateCountry(_fixture.Create <string>()); Assert.That(result, Is.TypeOf <ViewResult>()); }
public async Task UpdateCountry_WhenCalledWithCode_ReturnsViewResultWhereViewNameIsEqualToUpdateCountry() { Controller sut = CreateSut(); ViewResult result = (ViewResult)await sut.UpdateCountry(_fixture.Create <string>()); Assert.That(result.ViewName, Is.EqualTo("UpdateCountry")); }
public async Task UpdateCountry_WhenCalledWithCode_AssertQueryAsyncWasCalledOnQueryBus() { Controller sut = CreateSut(); string code = _fixture.Create <string>(); await sut.UpdateCountry(code); _queryBusMock.Verify(m => m.QueryAsync <IGetCountryQuery, ICountry>(It.Is <IGetCountryQuery>(value => string.CompareOrdinal(value.CountryCode, code.ToUpper()) == 0)), Times.Once); }
public async Task UpdateCountry_WhenCalledWithValidModel_ReturnsRedirectToActionResultWhereActionNameIsEqualToCountries() { Controller sut = CreateSut(); CountryViewModel model = CreateModel(); RedirectToActionResult result = (RedirectToActionResult)await sut.UpdateCountry(model); Assert.That(result.ActionName, Is.EqualTo("Countries")); }
public async Task UpdateCountry_WhenCalledWithValidModel_ReturnsRedirectToActionResult() { Controller sut = CreateSut(); CountryViewModel model = CreateModel(); IActionResult result = await sut.UpdateCountry(model); Assert.That(result, Is.TypeOf <RedirectToActionResult>()); }
public async Task UpdateCountry_WhenCalledWithInvalidModel_ReturnsViewResultWhereViewNameIsEqualToUpdateCountry() { Controller sut = CreateSut(modelIsValid: false); CountryViewModel model = CreateModel(); ViewResult result = (ViewResult)await sut.UpdateCountry(model); Assert.That(result.ViewName, Is.EqualTo("UpdateCountry")); }
public async Task UpdateCountry_WhenCalledWithInvalidModel_AssertPublishAsyncWasNotCalledOnCommandBus() { Controller sut = CreateSut(modelIsValid: false); CountryViewModel model = CreateModel(); await sut.UpdateCountry(model); _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IUpdateCountryCommand>()), Times.Never); }
public async Task UpdateCountry_WhenCalledWithInvalidModel_ReturnsViewResultWhereModelIsEqualToInvalidModel() { Controller sut = CreateSut(modelIsValid: false); CountryViewModel model = CreateModel(); ViewResult result = (ViewResult)await sut.UpdateCountry(model); Assert.That(result.Model, Is.TypeOf <CountryViewModel>()); CountryViewModel countryViewModel = (CountryViewModel)result.Model; Assert.That(countryViewModel, Is.EqualTo(model)); }
public async Task UpdateCountry_WhenCalledWithValidModel_AssertPublishAsyncWasCalledOnCommandBus() { Controller sut = CreateSut(); CountryViewModel model = CreateModel(); await sut.UpdateCountry(model); _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateCountryCommand>(command => string.CompareOrdinal(command.CountryCode, model.Code.ToUpper()) == 0 && string.CompareOrdinal(command.Name, model.Name) == 0 && string.CompareOrdinal(command.UniversalName, model.UniversalName) == 0 && string.CompareOrdinal(command.PhonePrefix, model.PhonePrefix) == 0)), Times.Once); }
public async Task UpdateCountry_WhenCalledWithCode_ReturnsViewResultWhereModelIsCountryViewModel() { string code = _fixture.Create <string>(); string name = _fixture.Create <string>(); string universalName = _fixture.Create <string>(); string phonePrefix = _fixture.Create <string>(); ICountry country = _fixture.BuildCountryMock(code, name, universalName, phonePrefix).Object; Controller sut = CreateSut(country); ViewResult result = (ViewResult)await sut.UpdateCountry(_fixture.Create <string>()); Assert.That(result.Model, Is.TypeOf <CountryViewModel>()); CountryViewModel countryViewModel = (CountryViewModel)result.Model; Assert.That(countryViewModel, Is.Not.Null); Assert.That(countryViewModel.Code, Is.EqualTo(code)); Assert.That(countryViewModel.Name, Is.EqualTo(name)); Assert.That(countryViewModel.UniversalName, Is.EqualTo(universalName)); Assert.That(countryViewModel.PhonePrefix, Is.EqualTo(phonePrefix)); Assert.That(countryViewModel.EditMode, Is.EqualTo(EditMode.Edit)); }
public void UpdateCountry_WhenCalledWithCodeWhereCodeIsWhiteSpace_ThrowsArgumentNullException() { Controller sut = CreateSut(); ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdateCountry(" ")); Assert.That(result.ParamName, Is.EqualTo("code")); }
public void UpdateCountry_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException() { Controller sut = CreateSut(); ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdateCountry((CountryViewModel)null)); Assert.That(result.ParamName, Is.EqualTo("countryViewModel")); }