public async Task QueryAsync_WhenCalledAndCountryCollectionWasNotReturnedFromContactRepository_AssertApplyLogicForPrincipalWasNotCalledOnCountryHelper() { QueryHandler sut = CreateSut(false); await sut.QueryAsync(new EmptyQuery()); _countryHelperMock.Verify(m => m.ApplyLogicForPrincipal(It.IsAny <IEnumerable <ICountry> >()), Times.Never); }
public async Task QueryAsync_WhenCalled_AssertGetCountriesAsyncWasCalledOnContactRepository() { QueryHandler sut = CreateSut(); await sut.QueryAsync(new EmptyQuery()); _contactRepositoryMock.Verify(m => m.GetCountriesAsync(), Times.Once); }
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_WhenCalledAndCountryCollectionWasReturnedFromContactRepository_ReturnsCountryCollectionFromCountryHelper() { IEnumerable <ICountry> countryCollection = _fixture.CreateMany <ICountry>(_random.Next(5, 10)).ToList(); QueryHandler sut = CreateSut(countryCollection: countryCollection); IEnumerable <ICountry> result = await sut.QueryAsync(new EmptyQuery()); Assert.That(result, Is.EqualTo(countryCollection)); }
public async Task QueryAsync_WhenCalledAndCountryCollectionWasReturnedFromContactRepository_AssertApplyLogicForPrincipalWasCalledOnCountryHelperWithCountryCollectionFromContactRepository() { IEnumerable <ICountry> countryCollection = _fixture.CreateMany <ICountry>(_random.Next(5, 10)).ToList(); QueryHandler sut = CreateSut(countryCollection: countryCollection); await sut.QueryAsync(new EmptyQuery()); _countryHelperMock.Verify(m => m.ApplyLogicForPrincipal(It.Is <IEnumerable <ICountry> >(value => Equals(value, countryCollection))), Times.Once); }
public async Task QueryAsync_WhenCalledAndCountryCollectionWasNotReturnedFromContactRepository_ReturnsEmptyCountryCollection() { QueryHandler sut = CreateSut(false); IList <ICountry> result = (await sut.QueryAsync(new EmptyQuery())).ToList(); Assert.That(result, Is.Not.Null); Assert.That(result, Is.Empty); }