本文整理汇总了C#中UnitOfWork.RemoveEmployee方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.RemoveEmployee方法的具体用法?C# UnitOfWork.RemoveEmployee怎么用?C# UnitOfWork.RemoveEmployee使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork.RemoveEmployee方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveEmployeeWithReports
public void RemoveEmployeeWithReports()
{
using (FakeEmployeeContext ctx = new FakeEmployeeContext())
{
UnitOfWork unit = new UnitOfWork(ctx);
Employee emp = new Employee();
Employee man = new Employee();
unit.AddEmployee(emp);
unit.AddEmployee(man);
emp.Manager = man;
unit.RemoveEmployee(man);
Assert.IsFalse(ctx.Employees.Contains(man), "Employee was not removed from underlying context.");
Assert.AreEqual(0, man.Reports.Count, "Employee was not removed from managers reports.");
Assert.IsNull(emp.Manager, "Manager property on Employee was not cleared.");
}
}
示例2: RemoveEmployee
public void RemoveEmployee()
{
using (FakeEmployeeContext ctx = new FakeEmployeeContext())
{
UnitOfWork unit = new UnitOfWork(ctx);
Employee emp = new Employee();
unit.AddEmployee(emp);
unit.RemoveEmployee(emp);
Assert.IsFalse(ctx.Employees.Contains(emp), "Employee was not removed from underlying context.");
}
}
示例3: RemoveEmployeeOutsideUnitOfWork
public void RemoveEmployeeOutsideUnitOfWork()
{
using (FakeEmployeeContext ctx = new FakeEmployeeContext())
{
UnitOfWork unit = new UnitOfWork(ctx);
try
{
unit.RemoveEmployee(new Employee());
Assert.Fail("Removing an Employee that was not added to Unit of Work did not throw.");
}
catch (InvalidOperationException ex)
{
Assert.AreEqual("The supplied Employee is not part of this Unit of Work.", ex.Message);
}
}
}
示例4: NullArgumentChecks
public void NullArgumentChecks()
{
using (FakeEmployeeContext ctx = new FakeEmployeeContext())
{
UnitOfWork unit = new UnitOfWork(ctx);
Utilities.CheckNullArgumentException(() => { new UnitOfWork(null); }, "context", "ctor");
Utilities.CheckNullArgumentException(() => { unit.AddEmployee(null); }, "employee", "AddEmployee");
Utilities.CheckNullArgumentException(() => { unit.AddDepartment(null); }, "department", "AddDepartment");
Utilities.CheckNullArgumentException(() => { unit.AddContactDetail(new Employee(), null); }, "detail", "AddContactDetail");
Utilities.CheckNullArgumentException(() => { unit.AddContactDetail(null, new Phone()); }, "employee", "AddContactDetail");
Utilities.CheckNullArgumentException(() => { unit.RemoveEmployee(null); }, "employee", "RemoveEmployee");
Utilities.CheckNullArgumentException(() => { unit.RemoveDepartment(null); }, "department", "RemoveDepartment");
Utilities.CheckNullArgumentException(() => { unit.RemoveContactDetail(null, new Phone()); }, "employee", "RemoveContactDetail");
Utilities.CheckNullArgumentException(() => { unit.RemoveContactDetail(new Employee(), null); }, "detail", "RemoveContactDetail");
}
}