public void ShouldNotAddMetadata_WhenValueIsNull() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; m.Country = null; m.Device = string.Empty; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = new POCO(); ttc.POCOes.Add(entity); ttc.SaveChanges(); entity.AssertAuditForAddition(ttc, entity.Id, null, x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(ttc, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23", ["Device"] = string.Empty }); } }
public async Task ShouldAddSingleMetadata_WhenSingleMetadataIsProvided_Async() { var options = new DbContextOptionsBuilder <TestTrackerContext>() .UseSqlServer(TestConnectionString) .Options; using (TestTrackerContext ttc = new TestTrackerContext(options)) { ttc.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = new POCO(); ttc.POCOes.Add(entity); await ttc.SaveChangesAsync("bilal"); entity.AssertAuditForAddition(ttc, entity.Id, "bilal", x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(ttc, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23" }); } }
public async Task ShouldAddSingleMetadata_WhenSingleMetadataIsProvided_Async() { Db.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = ObjectFactory.Create <POCO>(); Db.POCOs.Add(entity); await Db.SaveChangesAsync("bilal"); entity.AssertAuditForAddition(Db, entity.Id, "bilal", x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(Db, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23" }); }
public void ShouldNotAddMetadata_WhenValueIsNull() { Db.ConfigureMetadata(m => { m.IpAddress = "192.168.2.23"; m.Country = null; m.Device = string.Empty; }); EntityTracker.TrackAllProperties <POCO>(); POCO entity = ObjectFactory.Create <POCO>(); Db.POCOs.Add(entity); Db.SaveChanges(); entity.AssertAuditForAddition(Db, entity.Id, null, x => x.Color, x => x.Height, x => x.StartTime, x => x.Id); entity.AssertMetadata(Db, entity.Id, new Dictionary <string, string> { ["IpAddress"] = "192.168.2.23", ["Device"] = string.Empty }); }