public void CreateObject() { // 虚设上下文应该创建实际基类型,而不是从其派生的类型 using (FakeEmployeeContext ctx = new FakeEmployeeContext()) { object entity = ctx.CreateObject<Department>(); Assert.AreEqual(typeof(Department), entity.GetType(), "Department did not get created."); entity = ctx.CreateObject<Employee>(); Assert.AreEqual(typeof(Employee), entity.GetType(), "Employee did not get created."); entity = ctx.CreateObject<Email>(); Assert.AreEqual(typeof(Email), entity.GetType(), "Email did not get created."); entity = ctx.CreateObject<Phone>(); Assert.AreEqual(typeof(Phone), entity.GetType(), "Phone did not get created."); entity = ctx.CreateObject<Address>(); Assert.AreEqual(typeof(Address), entity.GetType(), "Address did not get created."); } }
public void CreateObject() { // Fake context should create the actual base type and not a type derived from it using (FakeEmployeeContext ctx = new FakeEmployeeContext()) { object entity = ctx.CreateObject <Department>(); Assert.AreEqual(typeof(Department), entity.GetType(), "Department did not get created."); entity = ctx.CreateObject <Employee>(); Assert.AreEqual(typeof(Employee), entity.GetType(), "Employee did not get created."); entity = ctx.CreateObject <Email>(); Assert.AreEqual(typeof(Email), entity.GetType(), "Email did not get created."); entity = ctx.CreateObject <Phone>(); Assert.AreEqual(typeof(Phone), entity.GetType(), "Phone did not get created."); entity = ctx.CreateObject <Address>(); Assert.AreEqual(typeof(Address), entity.GetType(), "Address did not get created."); } }
public void CreateObject() { // Fake context should create the actual base type and not a type derived from it using (FakeEmployeeContext ctx = new FakeEmployeeContext()) { object entity = ctx.CreateObject<Department>(); Assert.AreEqual(typeof(Department), entity.GetType(), "Department did not get created."); entity = ctx.CreateObject<Employee>(); Assert.AreEqual(typeof(Employee), entity.GetType(), "Employee did not get created."); entity = ctx.CreateObject<Email>(); Assert.AreEqual(typeof(Email), entity.GetType(), "Email did not get created."); entity = ctx.CreateObject<Phone>(); Assert.AreEqual(typeof(Phone), entity.GetType(), "Phone did not get created."); entity = ctx.CreateObject<Address>(); Assert.AreEqual(typeof(Address), entity.GetType(), "Address did not get created."); } }
public void CreateObject() { // 虚设上下文应该创建实际基类型,而不是从其派生的类型 using (FakeEmployeeContext ctx = new FakeEmployeeContext()) { object entity = ctx.CreateObject <Department>(); Assert.AreEqual(typeof(Department), entity.GetType(), "Department did not get created."); entity = ctx.CreateObject <Employee>(); Assert.AreEqual(typeof(Employee), entity.GetType(), "Employee did not get created."); entity = ctx.CreateObject <Email>(); Assert.AreEqual(typeof(Email), entity.GetType(), "Email did not get created."); entity = ctx.CreateObject <Phone>(); Assert.AreEqual(typeof(Phone), entity.GetType(), "Phone did not get created."); entity = ctx.CreateObject <Address>(); Assert.AreEqual(typeof(Address), entity.GetType(), "Address did not get created."); } }