public void DeleteWithoutVersionNo() { Fixture.CleanupAuditTable(); City city = new City { Name = "Ahmedabad", State = "GU", Latitude = 10.65m, Longitude = 11.50m, CreatedBy = Fixture.CurrentUserId }; Repository <City> cityRepo = new Repository <City>(Fixture.Connection); var id = cityRepo.Add(city); Assert.True(cityRepo.Delete(id, Fixture.CurrentUserId)); city = new City(); city = cityRepo.ReadOne(id); Assert.Equal(2, city.VersionNo); //read version no from history AuditTrailRepository <City> atRepo = new AuditTrailRepository <City>(Fixture.Connection); List <AuditTrail> lstAudit = atRepo.ReadAllAuditTrail(id).Cast <AuditTrail>().ToList(); Assert.Equal(1, lstAudit[0].RecordVersionNo); Assert.Equal(2, lstAudit[1].RecordVersionNo); }
public void AuditTrailNoEntityBase() { Employee emp = new Employee { EmployeeName = "Rajesh", Department = "AC", DOB = null, }; Fixture.CleanupAuditTable(); Repository <Employee> empRepo = new Repository <Employee>(Fixture.Connection); //add record var id = empRepo.Add(emp); //read history var empHistory = empRepo.ReadHistory(id); Assert.Single(empHistory); Assert.Equal("Rajesh", empHistory.First().EmployeeName); Assert.Equal("AC", empHistory.First().Department); Assert.Null(empHistory.First().DOB); AuditTrailRepository <Employee> auditRepo = new AuditTrailRepository <Employee>(Fixture.Connection); //read history var history = auditRepo.ReadAllAuditTrail(id); Assert.Single(history); Assert.Equal("Rajesh", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "EmployeeName").NewValue); Assert.Equal("AC", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "Department").NewValue); Assert.Null(history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "DOB")); }
public void AuditTrailPipeInText() { Fixture.CleanupAuditTable(); Repository <Employee> empRepo = new Repository <Employee>(Fixture.Connection); Employee emp = new Employee { EmployeeName = "Rajesh", Department = "AC|IT", DOB = new DateTime(1980, 7, 22), }; //add record var id = empRepo.Add(emp); //update record emp.Department = "IT"; emp.DOB = new DateTime(1983, 7, 22); empRepo.Update(emp); //read history var empHistory = empRepo.ReadHistory(id); Assert.Equal(2, empHistory.Count()); Assert.Equal("Rajesh", empHistory.First().EmployeeName); Assert.Equal("AC|IT", empHistory.First().Department); Assert.Equal(new DateTime(1980, 7, 22), empHistory.First().DOB); Assert.Equal("IT", empHistory.ElementAt(1).Department); Assert.Equal(new DateTime(1983, 7, 22), empHistory.ElementAt(1).DOB); AuditTrailRepository <Employee> auditRepo = new AuditTrailRepository <Employee>(Fixture.Connection); //read audittrail var history = auditRepo.ReadAllAuditTrail(id); Assert.Equal(2, history.Count); Assert.Equal("Rajesh", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "EmployeeName").NewValue); Assert.Equal("AC|IT", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "Department").NewValue); Assert.Equal(new DateTime(1980, 7, 22), DateTime.Parse(history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "DOB").NewValue)); Assert.Equal("IT", history.ElementAt(1).lstAuditTrailDetail.Find(p => p.ColumnName == "Department").NewValue); Assert.Equal("AC|IT", history.ElementAt(1).lstAuditTrailDetail.Find(p => p.ColumnName == "Department").OldValue); Assert.Equal(new DateTime(1983, 7, 22), DateTime.Parse(history.ElementAt(1).lstAuditTrailDetail.Find(p => p.ColumnName == "DOB").NewValue)); Assert.Equal(new DateTime(1980, 7, 22), DateTime.Parse(history.ElementAt(1).lstAuditTrailDetail.Find(p => p.ColumnName == "DOB").OldValue)); }
public void AuditTrailOldNewforExistingRecords() { Fixture.CleanupAuditTable(); Employee emp = new Employee { EmployeeId = 1, EmployeeName = "Rajesh", Department = "AC", DOB = null, }; //add values as it was earlier AuditTrail audit = new AuditTrail { lstAuditTrailDetail = new System.Collections.Generic.List <IAuditTrailDetail>() { new AuditTrailDetail() { ColumnName = "EmployeeName", NewValue = "\"Rajesh\"", }, new AuditTrailDetail() { ColumnName = "Department", NewValue = "\"AC\"", } } }; AuditTrailRepository <Employee> auditRepo = new AuditTrailRepository <Employee>(Fixture.Connection); auditRepo.Add(emp, RecordOperationEnum.Insert, audit); audit = new AuditTrail { lstAuditTrailDetail = new System.Collections.Generic.List <IAuditTrailDetail>() { new AuditTrailDetail() { ColumnName = "EmployeeName", NewValue = "\"Rakesh\"", OldValue = "\"Rajesh\"", }, new AuditTrailDetail() { ColumnName = "Department", NewValue = "\"IT\"", OldValue = "\"AC\"", }, new AuditTrailDetail() { ColumnName = "DOB", NewValue = "1980-7-22" } } }; auditRepo.Add(emp, RecordOperationEnum.Update, audit); //read history var history = auditRepo.ReadAllAuditTrail(1); Assert.Equal(2, history.Count); Assert.Equal("Rajesh", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "EmployeeName").NewValue); Assert.Equal("AC", history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "Department").NewValue); Assert.Null(history.First().lstAuditTrailDetail.Find(p => p.ColumnName == "DOB")); }