Esempio n. 1
0
        public void WhenRetrievingEmployeeByIdShouldReturnSingleEmployee()
        {
            // Arrange
            var expectedId = Guid.NewGuid();
            var employeeRepositoryMock = new Mock<IEntityRepository<Employee>>(MockBehavior.Strict);
            employeeRepositoryMock.Setup(r => r.Single(It.IsAny<IQueryObject<Employee>>(), It.IsAny<string[]>()))
                                  .Returns(new Employee { Id = expectedId });
            var employeeService = new EmployeeService(employeeRepositoryMock.Object);

            // Act
            var actual = employeeService.SingleById(expectedId);

            // Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(expectedId, actual.Id);
            employeeRepositoryMock.Verify(r => r.Single(It.IsAny<IQueryObject<Employee>>(), It.IsAny<string[]>()), Times.Once());
        }
Esempio n. 2
0
        public void GetEmployeeById()
        {
            // Arrange
            var repository = new EntityRepository<Employee>(this.Context);
            var employeeService = new EmployeeService(repository);
            var expectedFirstName = "TestName";
            var expectedLastName = "TestLastName";
            var expectedEmail = "*****@*****.**";
            var employee = this.CreateEmployee(expectedFirstName, expectedLastName, expectedEmail);
            var savedEmployee = employeeService.Save(employee);

            // Act
            var actual = employeeService.SingleById(savedEmployee.Id);

            // Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(expectedFirstName, actual.FirstName);
            Assert.AreEqual(expectedLastName, actual.LastName);
            Assert.IsNotNull(actual.Profile);
            Assert.IsNotNull(actual.Profile.Bio);
        }