public async Task UpdateTest() { //Arrange uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context)); SetGenericAuditHelper(); genericAudit.Action = 1; //Act await uow.AuditRepository.AddAsync(genericAudit); await uow.CommitAsync(); var existingAudit = uow.AuditRepository.GetByIdAsync(1).Result; existingAudit.Message = $"[UPDATE TEST] " + existingAudit.Message; existingAudit.CreatedAt = DateTime.UtcNow; uow.AuditRepository.Update(existingAudit); await uow.CommitAsync(); var actualAudit = uow.AuditRepository.GetByIdAsync(1).Result; //Assert actualAudit.Message.Should().StartWith("[UPDATE TEST]"); actualAudit.CreatedAt.Should().Be(existingAudit.CreatedAt); }
public async Task DeleteTest() { //Arrange uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context)); SetGenericAuditHelper(); genericAudit.Action = 1; //Act await uow.AuditRepository.AddAsync(genericAudit); await uow.CommitAsync(); uow.AuditRepository.Delete(genericAudit); await uow.CommitAsync(); var actualAudit = uow.AuditRepository.GetByIdAsync(genericAudit.Id); //Assert actualAudit.Result.Should().BeNull(); }
/// <summary> /// Add async helper. /// </summary> /// <param name="actionTypeId">action type id to use.</param> private async Task AddAsyncHelper(int actionTypeId) { //Arrange uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context)); SetGenericAuditHelper(); genericAudit.Action = actionTypeId; //Act await uow.AuditRepository.AddAsync(genericAudit); await uow.CommitAsync(); var actualAudit = await uow.AuditRepository.GetByIdAsync(genericAudit.Id); //Assert actualAudit.Should().NotBeNull(); actualAudit.Message.Should().Be(genericAudit.Message); }
public async Task GetAllAuditsTest() { //Arrange uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context)); var repository = new Repository.Implementations.AuditRepository(_context); SetGenericAuditHelper(); genericAudit.Action = 1; //Act await uow.AuditRepository.AddAsync(genericAudit); await uow.CommitAsync(); var audits = uow.AuditRepository.GetAll(); //Assert audits.Should().HaveCountGreaterThan(0); }
public async Task GetManyTest() { //Arrange SetGenericAuditHelper(); genericAudit.Action = 1; var pdsContext = Pds.Shared.Audit.Repository.Tests.Helper.SetUpHelper.GetInMemoryPdsDbContext(); uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context)); //Act await uow.AuditRepository.AddAsync(genericAudit); await uow.CommitAsync(); var actualAudit = uow.AuditRepository.GetMany(w => w.Action == 0); //Assert actualAudit.Should().NotBeNull(); }