public async void QueryAsync_MustCheck_Parameters() { // Arrange var repository = new ReadOnlyRepositoryFixture(false); // Act // Assert await Assert.ThrowsAsync <ArgumentNullException>(async() => await repository.QueryAsync(null, 0, 100)); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await repository.QueryAsync((o) => false, -1, 100)); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await repository.QueryAsync((o) => false, 0, -1)); await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await repository.QueryAsync((o) => false, 0, 1, (SortOrder)(-1))); }
public async void QueryAsync_MustReturn_Entity(bool includeReferences) { // Arrange var sut = new ReadOnlyRepositoryFixture(includeReferences); var entite = sut.Configuration.DbSet.First(); var entities = sut.Configuration.DbSet.Where(e => e.Id != entite.Id).OrderBy(e => e.Id); var enumerator = entities.GetEnumerator(); // Act var computed = await sut.QueryAsync(e => e.Id != entite.Id, 0, int.MaxValue); // Assert Assert.Equal(entities.Count(), computed.Count()); Assert.All(computed, c => { enumerator.MoveNext(); Assert.Equal(enumerator.Current.Id, c.Id); if (includeReferences) { Assert.NotNull(enumerator.Current.Reference); Assert.NotNull(enumerator.Current.Collection); Assert.NotEmpty(enumerator.Current.Collection); } }); }