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")); }
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); }
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); }
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); }
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); }
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)); }
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); }
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); }