예제 #1
0
        public void FindOrganizationDepartmentById_Service_Success()
        {
            // Arrange
            organizationDepartmentService = new OrganizationDepartmentService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object);
            mockRepository.Setup(x => x.FindById <OrganizationDepartment>(It.IsAny <int>())).Returns(new OrganizationDepartment()).Verifiable();

            // Act
            var response = organizationDepartmentService.FindOrganizationDepartmentById(It.IsAny <int>());

            // Assert
            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Result);
            Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <OrganizationDepartmentDto>));
            mockRepository.Verify(x => x.FindById <OrganizationDepartment>(It.IsAny <int>()), Times.Once);
        }
예제 #2
0
        public void GetAllOrganizationDepartments_Service_Fail()
        {
            // Arrange
            organizationDepartmentService = new OrganizationDepartmentService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object);
            mockRepository.Setup(x => x.All <OrganizationDepartment>()).Throws(new Exception()).Verifiable();

            // Act
            var response = organizationDepartmentService.GetAllOrganizationDepartments();

            // Assert
            Assert.IsNotNull(response);
            Assert.IsNull(response.Result);
            Assert.IsTrue(response.Notifications.HasErrors());
            Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <IEnumerable <OrganizationDepartmentDto> >));
            mockRepository.Verify(x => x.All <OrganizationDepartment>(), Times.Once);
        }
예제 #3
0
        public void DeleteOrganizationDepartmentById_Service_Fail()
        {
            // Arrange
            organizationDepartmentService = new OrganizationDepartmentService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object);
            mockRepository.Setup(x => x.Delete <OrganizationDepartment>(It.IsAny <int>())).Returns(false).Verifiable();

            // Act
            var response = organizationDepartmentService.DeleteOrganizationDepartment(It.IsAny <int>());

            // Assert
            Assert.IsNotNull(response);
            Assert.IsFalse(response.Result);
            Assert.IsTrue(response.Notifications.HasErrors());
            Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>));
            mockRepository.Verify(x => x.Delete <OrganizationDepartment>(It.IsAny <int>()), Times.Once);
        }