当前位置: 首页>>代码示例>>C#>>正文


C# UnitOfWork.RemoveDepartment方法代码示例

本文整理汇总了C#中UnitOfWork.RemoveDepartment方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.RemoveDepartment方法的具体用法?C# UnitOfWork.RemoveDepartment怎么用?C# UnitOfWork.RemoveDepartment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork.RemoveDepartment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveDepartmentWithEmployees

        public void RemoveDepartmentWithEmployees()
        {
            using (FakeEmployeeContext ctx = new FakeEmployeeContext())
            {
                UnitOfWork unit = new UnitOfWork(ctx);
                Department dep = new Department();
                Employee emp = new Employee();
                unit.AddDepartment(dep);
                unit.AddEmployee(emp);
                emp.Department = dep;

                unit.RemoveDepartment(dep);
                Assert.IsFalse(ctx.Departments.Contains(dep), "Department was not removed from underlying context.");
                Assert.IsNull(emp.Department, "Employee.Department property has not been nulled when deleting department.");
                Assert.IsNull(emp.DepartmentId, "Employee.DepartmentId property has not been nulled when deleting department.");
                Assert.AreEqual(0, dep.Employees.Count, "Department.Employees collection was not cleared when deleting department.");
            }
        }
开发者ID:jetlive,项目名称:skiaming,代码行数:18,代码来源:UnitOfWorkTests.cs

示例2: RemoveDepartment

        public void RemoveDepartment()
        {
            using (FakeEmployeeContext ctx = new FakeEmployeeContext())
            {
                UnitOfWork unit = new UnitOfWork(ctx);
                Department dep = new Department();
                unit.AddDepartment(dep);

                unit.RemoveDepartment(dep);
                Assert.IsFalse(ctx.Departments.Contains(dep), "Department was not removed from underlying context.");
            }
        }
开发者ID:jetlive,项目名称:skiaming,代码行数:12,代码来源:UnitOfWorkTests.cs

示例3: RemoveDepartmentOutsideUnitOfWork

 public void RemoveDepartmentOutsideUnitOfWork()
 {
     using (FakeEmployeeContext ctx = new FakeEmployeeContext())
     {
         UnitOfWork unit = new UnitOfWork(ctx);
         try
         {
             unit.RemoveDepartment(new Department());
             Assert.Fail("Removing a Department that was not added to Unit of Work did not throw.");
         }
         catch (InvalidOperationException ex)
         {
             Assert.AreEqual("The supplied Department is not part of this Unit of Work.", ex.Message);
         }
     }
 }
开发者ID:jetlive,项目名称:skiaming,代码行数:16,代码来源:UnitOfWorkTests.cs

示例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");
            }
        }
开发者ID:jetlive,项目名称:skiaming,代码行数:19,代码来源:UnitOfWorkTests.cs


注:本文中的UnitOfWork.RemoveDepartment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。