public async Task GetAsync_TwoGenericVersion_Success_Should_ReturnFalse() { IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var exist = await repository.CheckExistAsync(Guid.NewGuid()); exist.Should().BeFalse(); }
public async Task GetOrDefaultAsync_TwoGenericVersion_Success_Should_ReturnNull() { IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var entity = await repository.GetOrDefaultAsync(Guid.NewGuid()); entity.Should().BeNull(); }
public async Task GetAsync_TwoGenericVersion_Failure_Should_ThrowInvalidOperationException() { IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); Func <Task> act = () => repository.GetAsync(Guid.NewGuid()); await act.Should().ThrowExactlyAsync <InvalidOperationException>() .WithMessage("entity"); }
public async Task DeleteAsync_TwoGenericVersion_Success_Should_HaveZeroCountInTrackedEntities() { const int expCount = 0; IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var aggregateRoot = new TestAggregateRoot("testing"); var entry = await repository.DeleteAsync(aggregateRoot.Id); entry.Should().BeNull(); _Context.ChangeTracker.Entries <TestAggregateRoot>() .Should().HaveCount(expCount); }
public async Task GetAsync_TwoGenericVersion_Success_Should_ReturnTrue() { var aggregateRoot = new TestAggregateRoot("testing"); _Context.Add(aggregateRoot); await _Context.SaveChangesAsync(); _Context.ChangeTracker.Clear(); IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var exist = await repository.CheckExistAsync(aggregateRoot.Id); exist.Should().BeTrue(); }
public async Task GetOrDefaultAsync_TwoGenericVersion_Success_Should_ReturnEntityInDatabase() { var aggregateRoot = new TestAggregateRoot("testing"); _Context.Add(aggregateRoot); await _Context.SaveChangesAsync(); _Context.ChangeTracker.Clear(); IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var entity = await repository.GetOrDefaultAsync(aggregateRoot.Id); entity.Should().NotBeNull(); }
public async Task GetCountAsync_Success_Should_ReturnEntityInPaginatedList_Detail_ThirdPage() { var expCount = 5; _Context.AddRange(new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing")); await _Context.SaveChangesAsync(); _Context.ChangeTracker.Clear(); IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var count = await repository.GetCountAsync(); count.Should().Be(expCount); }
public async Task PaginateAsync_Success_Should_ReturnEntityInPaginatedList_Detail_ThirdPage() { var expCount = 0; var page = 2; var take = 3; _Context.AddRange(new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing"), new TestAggregateRoot("testing")); await _Context.SaveChangesAsync(); _Context.ChangeTracker.Clear(); IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var list = await repository.PaginateAsync(page, take); list.Should().HaveCount(expCount); }
public async Task DeleteAsync_TwoGenericVersion_Success_Should_AddEntityWithDeletedState() { const int expCount = 1; var aggregateRoot = new TestAggregateRoot("testing"); _Context.Add(aggregateRoot); await _Context.SaveChangesAsync(); _Context.ChangeTracker.Clear(); IRepositoryAsync <TestAggregateRoot, Guid> repository = new TestAggregateRootRepository2(_Context); var entry = await repository.DeleteAsync(aggregateRoot.Id); entry.Should().NotBeNull(); _Context.ChangeTracker.Entries <TestAggregateRoot>() .Should().HaveCount(expCount); _Context.ChangeTracker.Entries <TestAggregateRoot>() .Should().Contain(e => e.Entity.Id == aggregateRoot.Id && e.State == EntityState.Deleted); }