private void Logs(DbEntityEntry <BaseModel> entry) { LoggableEntity expected = new LoggableEntity(entry); logger.When(sub => sub.Log(Arg.Any <LoggableEntity>())).DoNotCallBase(); logger.When(sub => sub.Log(Arg.Any <LoggableEntity>())).Do(info => { LoggableEntity actual = info.Arg <LoggableEntity>(); Assert.Equal(expected.ToString(), actual.ToString()); Assert.Equal(expected.Action, actual.Action); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Id, actual.Id); }); logger.Log(new[] { entry }); logger.ReceivedWithAnyArgs().Log(expected); }
public void Log_DoesNotSaveLogs() { entry.State = EntityState.Added; DbContext context = Substitute.For <DbContext>(); logger = Substitute.ForPartsOf <AuditLogger>(context); logger.When(sub => sub.Log(Arg.Any <LoggableEntity>())).DoNotCallBase(); logger.Log(new[] { entry }); logger.DidNotReceive().Save(); context.DidNotReceive().SaveChanges(); }