public void TestRecordAndPlayDefault() { //Database.SetInitializer<ContextForDatabase>(new CreateDatabaseIfNotExists<ContextForDatabase>()); Database.SetInitializer <ContextForDatabase>(null); #region set record EF var record = new InterceptionRecordOrPlay(@"a.zip", ModeInterception.Record); DbInterception.Add(record); #endregion var employeeFromDatabase = EmployeeWithDepartment(); DbInterception.Remove(record); File.Copy("a.zip", "b.zip", true); #region set play what is recorded EF var play = new InterceptionRecordOrPlay(@"b.zip", ModeInterception.Play); DbInterception.Add(play); #endregion var employeeFromPlay = EmployeeWithDepartment(); // assert id's are equal Assert.AreEqual(employeeFromDatabase.Id, employeeFromPlay.Id); Assert.AreEqual(employeeFromDatabase.Department.Id, employeeFromPlay.Department.Id); DbInterception.Remove(play); }
public void VerifyIValidatableWorks() { Database.SetInitializer <ContextForDatabase>(null); #region set record EF var record = new InterceptionRecordOrPlay(@"VerifyIValidatableWorks.zip", ModeInterception.Play); DbInterception.Add(record); #endregion var e = new Employee(); e.ValidateEmployee = true; e.IDDepartment = 60000; var err = e.Validate(null).ToArray(); Assert.IsNotNull(err); Assert.AreEqual(1, err.Length); }