public void DetectChangesWithOneFieldAuditTrail() { AmplaRecord record = CreateRecord(100); AmplaAuditRecord auditRecord = CreateAuditRecord(record); IAmplaViewProperties <ProductionModel> viewProperties = GetViewProperties(); auditRecord.Changes = new List <AmplaAuditSession> { AddSession("User", DateTime.Today, "Value", "100", "200") }; ModifyRecordEventDectection <ProductionModel> recordEventDectection = new ModifyRecordEventDectection <ProductionModel>(record, auditRecord, viewProperties); List <AmplaRecordChanges> changes = recordEventDectection.DetectChanges(); Assert.That(changes, Is.Not.Empty); Assert.That(changes.Count, Is.EqualTo(1)); Assert.That(changes[0].User, Is.EqualTo("User")); Assert.That(changes[0].VersionDateTime, Is.EqualTo(DateTime.Today)); Assert.That(changes[0].Operation, Is.EqualTo("Modify Record")); Assert.That(changes[0].Changes, Is.Not.Empty); Assert.That(changes[0].Changes[0].Name, Is.EqualTo("Value")); Assert.That(changes[0].Changes[0].OriginalValue, Is.EqualTo("100")); Assert.That(changes[0].Changes[0].EditedValue, Is.EqualTo("200")); }
public void DetectChangesWithAuditTrailWithNoChangesInValues() { AmplaRecord record = CreateRecord(100); AmplaAuditRecord auditRecord = CreateAuditRecord(record); IAmplaViewProperties <ProductionModel> viewProperties = GetViewProperties(); auditRecord.Changes = new List <AmplaAuditSession> { AddSession("User", DateTime.Today, "Value", "100", "100"), AddSession("Admin", DateTime.Today.AddHours(1), new[] { "One", "Two" }, new[] { "11", "222" }, new[] { "111", "222" }) }; ModifyRecordEventDectection <ProductionModel> recordEventDectection = new ModifyRecordEventDectection <ProductionModel>(record, auditRecord, viewProperties); List <AmplaRecordChanges> changes = recordEventDectection.DetectChanges(); Assert.That(changes, Is.Not.Empty); Assert.That(changes.Count, Is.EqualTo(1)); Assert.That(changes[0].User, Is.EqualTo("Admin")); Assert.That(changes[0].VersionDateTime, Is.EqualTo(DateTime.Today.AddHours(1))); Assert.That(changes[0].Operation, Is.EqualTo("Modify Record")); Assert.That(changes[0].Changes, Is.Not.Empty); Assert.That(changes[0].Changes.Length, Is.EqualTo(1)); Assert.That(changes[0].Changes[0].Name, Is.EqualTo("One")); Assert.That(changes[0].Changes[0].OriginalValue, Is.EqualTo("11")); Assert.That(changes[0].Changes[0].EditedValue, Is.EqualTo("111")); }
public void DetectChangesWithNoAuditTrail() { AmplaRecord record = CreateRecord(100); AmplaAuditRecord auditRecord = CreateAuditRecord(record); IAmplaViewProperties <ProductionModel> viewProperties = GetViewProperties(); ModifyRecordEventDectection <ProductionModel> recordEventDectection = new ModifyRecordEventDectection <ProductionModel>(record, auditRecord, viewProperties); List <AmplaRecordChanges> changes = recordEventDectection.DetectChanges(); Assert.That(changes, Is.Empty); }
public void DetectChangesWithAuditTrailWithNoChangeInValue() { AmplaRecord record = CreateRecord(100); AmplaAuditRecord auditRecord = CreateAuditRecord(record); IAmplaViewProperties <ProductionModel> viewProperties = GetViewProperties(); auditRecord.Changes = new List <AmplaAuditSession> { AddSession("User", DateTime.Today, "Value", "100", "100") }; ModifyRecordEventDectection <ProductionModel> recordEventDectection = new ModifyRecordEventDectection <ProductionModel>(record, auditRecord, viewProperties); List <AmplaRecordChanges> changes = recordEventDectection.DetectChanges(); Assert.That(changes, Is.Empty); }
public void DetectChangesWithDeletedRecords() { AmplaRecord record = CreateRecord(100); AmplaAuditRecord auditRecord = CreateAuditRecord(record); IAmplaViewProperties <ProductionModel> viewProperties = GetViewProperties(); record.AddColumn("Sample Period", typeof(DateTime)); record.SetValue("Sample Period", Iso8601DateTimeConverter.ConvertFromLocalDateTime(DateTime.Today.AddDays(-1))); auditRecord.Changes = new List <AmplaAuditSession> { AddSession("User", DateTime.Today, "IsDeleted", "False", "True") }; ModifyRecordEventDectection <ProductionModel> recordEventDectection = new ModifyRecordEventDectection <ProductionModel>(record, auditRecord, viewProperties); List <AmplaRecordChanges> changes = recordEventDectection.DetectChanges(); Assert.That(changes, Is.Empty); }