コード例 #1
0
        public void SetEmployee_RequestNotExistingEmployee_SetsEmployeeInRepository()
        {
            // arrange
            Mock<IRepository> mockedRepository = CreateMockedRepository();
            var service = new EmployeeService(mockedRepository.Object);

            const int employeeId = 23;
            var employeeInfo = new EmployeeInfo
            {
                Id = employeeId
            };

            // act
            service.SetEmployee(employeeInfo);

            // assert
            mockedRepository.Verify(p => p.SetEmployee(It.Is<Employee>(e => e.Id == employeeId)));
        }
コード例 #2
0
        public void SetEmployee_EmployeeNullReference_ThrowsException()
        {
            // arrange
            Mock<IRepository> mockedRepository = CreateMockedRepository();
            var service = new EmployeeService(mockedRepository.Object);

            // act
            service.SetEmployee(null);
        }