示例#1
0
        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);
        }
示例#2
0
        public async Task GetByPredicateTest()
        {
            //Arrange
            uow = new Implementations.UnitOfWork(_context, new Implementations.AuditRepository(_context));
            SetGenericAuditHelper();
            genericAudit.Action = 1;

            //Act
            await uow.AuditRepository.AddAsync(genericAudit);

            await uow.CommitAsync();

            var actualAudit = uow.AuditRepository.GetByPredicate(x => x.Id == genericAudit.Id);

            //Assert
            actualAudit.Should().NotBeNull();
        }
示例#3
0
        /// <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);
        }
示例#4
0
        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);
        }
示例#5
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();
        }