コード例 #1
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountry_AssertGetCountryCodeWasCalledOnClaimResolver()
        {
            ICountryHelper sut = CreateSut();

            sut.ApplyLogicForPrincipal(_fixture.Create <ICountry>());

            _claimResolverMock.Verify(m => m.GetCountryCode(), Times.Once);
        }
コード例 #2
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountryCollection_AssertGetCountryCodeWasCalledOnClaimResolver()
        {
            ICountryHelper sut = CreateSut();

            sut.ApplyLogicForPrincipal(_fixture.CreateMany <ICountry>(_random.Next(5, 10)).ToList());

            _claimResolverMock.Verify(m => m.GetCountryCode(), Times.Once);
        }
コード例 #3
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountry_ReturnsCountry()
        {
            ICountryHelper sut = CreateSut();

            ICountry country = _fixture.Create <ICountry>();
            ICountry result  = sut.ApplyLogicForPrincipal(country);

            Assert.That(result, Is.EqualTo(country));
        }
コード例 #4
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountryCollection_ReturnsCountryCollection()
        {
            ICountryHelper sut = CreateSut();

            IEnumerable <ICountry> countryCollection = _fixture.CreateMany <ICountry>(_random.Next(5, 10)).ToList();
            IEnumerable <ICountry> result            = sut.ApplyLogicForPrincipal(countryCollection);

            Assert.That(result, Is.EqualTo(countryCollection));
        }
        public async Task <ICountry> QueryAsync(IGetCountryQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            query.Validate(_validator, _contactRepository);

            ICountry country = await _contactRepository.GetCountryAsync(query.CountryCode);

            return(country == null ? null : _countryHelper.ApplyLogicForPrincipal(country));
        }
コード例 #6
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountry_AssertApplyDefaultForPrincipalWasCalledOnCountry()
        {
            string         countryCode = _fixture.Create <string>();
            ICountryHelper sut         = CreateSut(countryCode);

            Mock <ICountry> countryMock = _fixture.BuildCountryMock();

            sut.ApplyLogicForPrincipal(countryMock.Object);

            countryMock.Verify(m => m.ApplyDefaultForPrincipal(It.Is <string>(value => string.CompareOrdinal(value, countryCode) == 0)), Times.Once());
        }
        public async Task <IEnumerable <ICountry> > QueryAsync(EmptyQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            IEnumerable <ICountry> countries = await _contactRepository.GetCountriesAsync();

            if (countries == null)
            {
                return(new List <ICountry>(0));
            }

            return(_countryHelper.ApplyLogicForPrincipal(countries));
        }
コード例 #8
0
        public async Task <IPostalCode> QueryAsync(IGetPostalCodeQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            query.Validate(_validator, _contactRepository);

            IPostalCode postalCode = await _contactRepository.GetPostalCodeAsync(query.CountryCode, query.PostalCode);

            if (postalCode == null)
            {
                return(null);
            }

            postalCode.Country = _countryHelper.ApplyLogicForPrincipal(postalCode.Country);

            return(postalCode);
        }
コード例 #9
0
        public void ApplyLogicForPrincipal_WhenCalledWithCountryCollection_AssertApplyDefaultForPrincipalWasCalledOnEachCountry()
        {
            string         countryCode = _fixture.Create <string>();
            ICountryHelper sut         = CreateSut(countryCode);

            IEnumerable <Mock <ICountry> > countryMockCollection = new List <Mock <ICountry> >
            {
                _fixture.BuildCountryMock(),
                                           _fixture.BuildCountryMock(),
                                           _fixture.BuildCountryMock()
            };

            sut.ApplyLogicForPrincipal(countryMockCollection.Select(countryMock => countryMock.Object).ToList());

            foreach (Mock <ICountry> countryMock in countryMockCollection)
            {
                countryMock.Verify(m => m.ApplyDefaultForPrincipal(It.Is <string>(value => string.CompareOrdinal(value, countryCode) == 0)), Times.Once());
            }
        }
        public async Task <IEnumerable <IPostalCode> > QueryAsync(IGetPostalCodeCollectionQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            query.Validate(_validator, _contactRepository);

            IEnumerable <IPostalCode> postalCodes = await _contactRepository.GetPostalCodesAsync(query.CountryCode);

            if (postalCodes == null)
            {
                return(new List <IPostalCode>(0));
            }

            return(postalCodes.Select(postalCode =>
            {
                postalCode.Country = _countryHelper.ApplyLogicForPrincipal(postalCode.Country);
                return postalCode;
            })
                   .ToList());
        }
コード例 #11
0
        public void ApplyLogicForPrincipal_WhenCountryCollectionIsNull_ThrowsArgumentNullException()
        {
            ICountryHelper sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ApplyLogicForPrincipal((IEnumerable <ICountry>)null));

            Assert.That(result.ParamName, Is.EqualTo("countryCollection"));
        }