Exemplo n.º 1
0
        public void QueryAsync_WhenQueryIsNull_ThrowsArgumentNullException()
        {
            QueryHandler sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("query"));
        }
Exemplo n.º 2
0
        public async Task QueryAsync_WhenCalledAndCountryWasNotReturnedFromContactRepository_AssertApplyLogicForPrincipalWasNotCalledOnCountryHelper()
        {
            QueryHandler sut = CreateSut(false);

            IGetCountryQuery query = CreateQueryMock().Object;
            await sut.QueryAsync(query);

            _countryHelperMock.Verify(m => m.ApplyLogicForPrincipal(It.IsAny <ICountry>()), Times.Never);
        }
Exemplo n.º 3
0
        public async Task QueryAsync_WhenCalled_AssertCountryCodeWasCalledOnGetCountryQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetCountryQuery> query = CreateQueryMock();
            await sut.QueryAsync(query.Object);

            query.Verify(m => m.CountryCode, Times.Once);
        }
Exemplo n.º 4
0
        public async Task QueryAsync_WhenCalledAndCountryWasNotReturnedFromContactRepository_ReturnsNull()
        {
            QueryHandler sut = CreateSut(false);

            IGetCountryQuery query  = CreateQueryMock().Object;
            ICountry         result = await sut.QueryAsync(query);

            Assert.That(result, Is.Null);
        }
Exemplo n.º 5
0
        public async Task QueryAsync_WhenCalled_AssertGetCountryAsyncWasCalledOnContactRepository()
        {
            QueryHandler sut = CreateSut();

            string           countryCode = _fixture.Create <string>();
            IGetCountryQuery query       = CreateQueryMock(countryCode).Object;
            await sut.QueryAsync(query);

            _contactRepositoryMock.Verify(m => m.GetCountryAsync(It.Is <string>(value => string.CompareOrdinal(value, countryCode) == 0)), Times.Once);
        }
Exemplo n.º 6
0
        public async Task QueryAsync_WhenCalledAndCountryWasReturnedFromContactRepository_ReturnsCountryFromCountryHelper()
        {
            ICountry     country = _fixture.BuildCountryMock().Object;
            QueryHandler sut     = CreateSut(country: country);

            IGetCountryQuery query  = CreateQueryMock().Object;
            ICountry         result = await sut.QueryAsync(query);

            Assert.That(result, Is.EqualTo(country));
        }
Exemplo n.º 7
0
        public async Task QueryAsync_WhenCalledAndCountryWasReturnedFromContactRepository_AssertApplyLogicForPrincipalWasCalledOnCountryHelperWithCountryFromContactRepository()
        {
            ICountry     country = _fixture.BuildCountryMock().Object;
            QueryHandler sut     = CreateSut(country: country);

            IGetCountryQuery query = CreateQueryMock().Object;
            await sut.QueryAsync(query);

            _countryHelperMock.Verify(m => m.ApplyLogicForPrincipal(It.Is <ICountry>(value => value == country)), Times.Once);
        }
Exemplo n.º 8
0
        public async Task QueryAsync_WhenCalled_AssertValidateWasCalledOnGetCountryQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetCountryQuery> query = CreateQueryMock();
            await sut.QueryAsync(query.Object);

            query.Verify(m => m.Validate(
                             It.Is <IValidator>(value => value == _validatorMock.Object),
                             It.Is <IContactRepository>(value => value == _contactRepositoryMock.Object)),
                         Times.Once);
        }