public async void Change_department_overlaped_weight_must_have_throws_exception() { //Arrange var repository = A.Fake <IRepository>(); var department = new Department(2, 8, 0, 0, 0, "Department3"); var departments = new List <Department>() { new Department(1, 0, 10, 0, 0, "Department1"), new Department(2, 10, 0, 0, 0, "Department2") }; A.CallTo(() => repository.ListAsync <Department>()).Returns(departments); var service = new DepartmentService(repository); //Act & Assert await Assert.ThrowsAsync <DomainException>(() => service.Change(department)); }
public async void Change_department_valid_parameters_must_have_called_update() { //Arrange var repository = A.Fake <IRepository>(); var department = new Department(2, 0, 0, 20, 0, "Department3"); var departments = new List <Department>() { new Department(1, 0, 0, 0, 10, "Department1"), new Department(2, 0, 0, 10, 20, "Department2") }; A.CallTo(() => repository.ListAsync <Department>()).Returns(departments); var service = new DepartmentService(repository); //Act await service.Change(department); //Assert A.CallTo(() => repository.Update <Department>(department)).MustHaveHappenedOnceExactly(); }