public void RemoveEmployee_ForDeliveredPackage_ShouldNotChangeItsStatus() { var package = new Package { Id = 1, Status = PackageStatus.Delivered }; var employee = new Employee { Id = 1, FirstName = "Ted" }; var mockContext = new Mock<InstantDeliveryContext>(); mockContext.Setup(c => c.Packages).ReturnsDbSet(package); mockContext.Setup(c => c.Employees).ReturnsDbSet(employee); var userStore = new Mock<UserStore<User>>(mockContext.Object); var userManager = new Mock<UserManager<User>>(userStore.Object); var controller = new EmployeesController(mockContext.Object, userManager.Object); controller.Delete(employee.Id); Assert.Equal(PackageStatus.Delivered, package.Status); }
public void RemoveEmployee_ForPackagesInDelivery_ShouldSetPackagesStatusBackToNew() { var package = new Package { Id = 1, Status = PackageStatus.InDelivery }; var employee = new Employee { Id = 1, FirstName = "Ted", LastName = "Mosby" }; employee.Packages.Add(package); var mockContext = new Mock<InstantDeliveryContext>(); mockContext.Setup(c => c.Packages).ReturnsDbSet(package); mockContext.Setup(c => c.Employees).ReturnsDbSet(employee); var userStore = new Mock<UserStore<User>>(mockContext.Object); var userManager = new Mock<UserManager<User>>(userStore.Object); var controller = new EmployeesController(mockContext.Object, userManager.Object); controller.Delete(employee.Id); Assert.Equal(PackageStatus.InWarehouse, package.Status); }