Exemplo n.º 1
0
        public async Task CreateContact_WhenContactViewModelIsValidTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.CreateContact(CreateContactViewModel());

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
        public async Task StartLoadingContacts_WhenNoTokenWasReturnedFromTokenHelperFactory_ReturnsUnauthorizedResult()
        {
            Controller sut = CreateSut(false);

            IActionResult result = await sut.StartLoadingContacts();

            Assert.That(result, Is.TypeOf <UnauthorizedResult>());
        }
        public async Task StartLoadingContacts_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereViewNameIsEqualToLoadingContactsPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts();

            Assert.That(result.ViewName, Is.EqualTo("_LoadingContactsPartial"));
        }
Exemplo n.º 4
0
        public void UpdatePostalCode_WhenCalledWithCountryCodeEqualToWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdatePostalCode(" ", _fixture.Create <string>()));

            Assert.That(result.ParamName, Is.EqualTo("countryCode"));
        }
        public async Task StartCreatingContact_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereViewNameIsEqualToCreatingContactPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartCreatingContact(_fixture.Create <string>());

            Assert.That(result.ViewName, Is.EqualTo("_CreatingContactPartial"));
        }
        public async Task DeleteCountry_WhenCalledWithCode_ReturnsRedirectToActionResultWhereControllerNameIsEqualToContact()
        {
            Controller sut = CreateSut();

            RedirectToActionResult result = (RedirectToActionResult)await sut.DeleteCountry(_fixture.Create <string>());

            Assert.That(result.ControllerName, Is.EqualTo("Contact"));
        }
Exemplo n.º 7
0
        public async Task UpdatePostalCode_WhenCalledWithCountryCodeAndPostalCode_ReturnsViewResultWhereViewNameIsEqualToUpdatePostalCode()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)await sut.UpdatePostalCode(_fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result.ViewName, Is.EqualTo("UpdatePostalCode"));
        }
        public async Task AddAssociatedCompany_WhenNoTokenWasReturnedFromTokenHelperFactory_ReturnsUnauthorizedResult()
        {
            Controller sut = CreateSut(false);

            IActionResult result = await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <UnauthorizedResult>());
        }
        public async Task AddAssociatedCompany_WhenNoCountryWasReturnedFromQueryBus_ReturnsBadRequestResult()
        {
            Controller sut = CreateSut(hasCountry: false);

            IActionResult result = await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <BadRequestResult>());
        }
Exemplo n.º 10
0
        public async Task CreateContact_WhenNoTokenWasReturnedFromTokenHelperFactory_ReturnsUnauthorizedResult()
        {
            Controller sut = CreateSut(false);

            IActionResult result = await sut.CreateContact(CreateContactViewModel());

            Assert.That(result, Is.TypeOf <UnauthorizedResult>());
        }
Exemplo n.º 11
0
        public async Task CreateContact_WhenContactViewModelIsInvalidTokenWasReturnedFromTokenHelperFactory_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(modelIsValid: false);

            await sut.CreateContact(CreateContactViewModel());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <ICreateContactCommand>()), Times.Never);
        }
Exemplo n.º 12
0
        public void CreateContact_WhenContactViewModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.CreateContact((ContactViewModel)null));

            Assert.That(result.ParamName, Is.EqualTo("contactViewModel"));
        }
Exemplo n.º 13
0
        public async Task CreateContact_WhenContactViewModelIsValidTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResultWhereRouteValuesIsNull()
        {
            Controller sut = CreateSut();

            RedirectToActionResult result = (RedirectToActionResult)await sut.CreateContact(CreateContactViewModel());

            Assert.That(result.RouteValues, Is.Null);
        }
Exemplo n.º 14
0
        public async Task CreateContact_WhenContactViewModelIsValidTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResultWhereActionNameIsEqualToContacts()
        {
            Controller sut = CreateSut();

            RedirectToActionResult result = (RedirectToActionResult)await sut.CreateContact(CreateContactViewModel());

            Assert.That(result.ActionName, Is.EqualTo("Contacts"));
        }
        public void DeleteCountry_WhenCalledWithCodeWhereCodeIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.DeleteCountry(" "));

            Assert.That(result.ParamName, Is.EqualTo("code"));
        }
        public async Task AddAssociatedCompany_WhenCountryWasReturnedFromQueryBus_ReturnsPartialViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <PartialViewResult>());
        }
        public async Task DeleteCountry_WhenCalledWithCode_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.DeleteCountry(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
        public async Task AddAssociatedCompany_WhenCountryWasReturnedFromQueryBus_ReturnsPartialViewResultWhereViewNameIsEqualToEditCompanyPartial()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result.ViewName, Is.EqualTo("_EditCompanyPartial"));
        }
Exemplo n.º 19
0
        public async Task UpdatePostalCode_WhenCalledWithCountryCodeAndPostalCode_ReturnsViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.UpdatePostalCode(_fixture.Create <string>(), _fixture.Create <string>());

            Assert.That(result, Is.TypeOf <ViewResult>());
        }
        public async Task AddAssociatedCompany_WhenCountryWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsCompanyViewModel()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result.Model, Is.TypeOf <CompanyViewModel>());
        }
Exemplo n.º 21
0
        public void UpdatePostalCode_WhenCalledWithModelWhereModelIsNull_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdatePostalCode(null));

            Assert.That(result.ParamName, Is.EqualTo("postalCodeViewModel"));
        }
        public async Task AddAssociatedCompany_WhenCountryWasReturnedFromQueryBus_ReturnsPartialViewResultWhereTemplateInfoWithinViewDataIsNotNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result.ViewData.TemplateInfo, Is.Not.Null);
        }
Exemplo n.º 23
0
        public void UpdatePostalCode_WhenCalledWithPostalCodeEqualToEmpty_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.UpdatePostalCode(_fixture.Create <string>(), string.Empty));

            Assert.That(result.ParamName, Is.EqualTo("postalCode"));
        }
        public async Task AddAssociatedCompany_WhenCountryWasReturnedFromQueryBus_ReturnsPartialViewResultWhereHtmlFieldPrefixInTemplateInfoWithinViewDataIsEqualToCompany()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.AddAssociatedCompany(_fixture.Create <string>());

            Assert.That(result.ViewData.TemplateInfo.HtmlFieldPrefix, Is.EqualTo("Company"));
        }
        public void StartCreatingContact_WhenCountryCodeIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.StartCreatingContact(" "));

            Assert.That(result.ParamName, Is.EqualTo("countryCode"));
        }
        public void AddAssociatedCompany_WhenCountryCodeIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.AddAssociatedCompany(" "));

            Assert.That(result.ParamName, Is.EqualTo("countryCode"));
        }
        public async Task StartLoadingContacts_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.StartLoadingContacts();

            Assert.That(result, Is.TypeOf <PartialViewResult>());
        }
        public async Task AddAssociatedCompany_WhenNoTokenWasReturnedFromTokenHelperFactory_AssertQueryAsyncWasNotCalledOnQueryBusWithGetCountryQuery()
        {
            Controller sut = CreateSut(false);

            await sut.AddAssociatedCompany(_fixture.Create <string>());

            _queryBusMock.Verify(m => m.QueryAsync <IGetCountryQuery, ICountry>(It.IsAny <IGetCountryQuery>()), Times.Never);
        }
        public async Task StartLoadingContacts_WhenTokenWasReturnedFromTokenHelperFactory_ReturnsPartialViewResultWhereModelIsContactOptionsViewModel()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.StartLoadingContacts();

            Assert.That(result.Model, Is.TypeOf <ContactOptionsViewModel>());
        }
Exemplo n.º 30
0
        public async Task PostalCodes_WhenCalledWithoutCountryCode_ReturnsViewResultWhereViewNameIsEqualToPostalCodes()
        {
            Controller sut = CreateSut();

            ViewResult result = (ViewResult)await sut.PostalCodes();

            Assert.That(result.ViewName, Is.EqualTo("PostalCodes"));
        }