public AuditedUnitOfWorkTests() { context = TestingContext.Create(); model = ObjectsFactory.CreateRole(0); unitOfWork = new AuditedUnitOfWork(context, 1); context.Drop().Add(model); context.SaveChanges(); }
public void Commit_AddedAudit() { context.Dispose(); unitOfWork.Dispose(); context = TestingContext.Create(); unitOfWork = new AuditedUnitOfWork(context, 1); unitOfWork.Insert(ObjectsFactory.CreateRole(1)); LoggableEntity expected = new(context.ChangeTracker.Entries <AModel>().Single()); unitOfWork.Commit(); AuditLog actual = Assert.Single(unitOfWork.Select <AuditLog>()); Assert.Equal(expected.ToString(), actual.Changes); Assert.Equal(expected.Name, actual.EntityName); Assert.Equal(expected.Action, actual.Action); Assert.Equal(expected.Id(), actual.EntityId); Assert.Equal(1, actual.AccountId); }