public void FindOrganizationBranchById_Service_Success() { // Arrange organizationBranchService = new OrganizationBranchService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.FindById <OrganizationBranch>(It.IsAny <int>())).Returns(new OrganizationBranch()).Verifiable(); // Act var response = organizationBranchService.FindOrganizationBranchById(It.IsAny <int>()); // Assert Assert.IsNotNull(response); Assert.IsNotNull(response.Result); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <OrganizationBranchDto>)); mockRepository.Verify(x => x.FindById <OrganizationBranch>(It.IsAny <int>()), Times.Once); }
public void DeleteOrganizationBranchById_Service_Fail() { // Arrange organizationBranchService = new OrganizationBranchService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.Delete <OrganizationBranch>(It.IsAny <int>())).Returns(false).Verifiable(); // Act var response = organizationBranchService.DeleteOrganizationBranch(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 <OrganizationBranch>(It.IsAny <int>()), Times.Once); }
public void GetAllOrganizationBranches_Service_Fail() { // Arrange organizationBranchService = new OrganizationBranchService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.All <OrganizationBranch>()).Throws(new Exception()).Verifiable(); // Act var response = organizationBranchService.GetAllOrganizationBranches(); // Assert Assert.IsNotNull(response); Assert.IsNull(response.Result); Assert.IsTrue(response.Notifications.HasErrors()); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <IEnumerable <OrganizationBranchDto> >)); mockRepository.Verify(x => x.All <OrganizationBranch>(), Times.Once); }
public void CreateOrganizationBranch_Service_Success() { // Arrange organizationBranchService = new OrganizationBranchService(mockRepository.Object, mockLogger.Object, mockCache.Object, mockTelemetry.Object); mockRepository.Setup(x => x.Insert(It.IsAny <OrganizationBranch>())).Returns(true).Verifiable(); // Act var organizationBranch = new OrganizationBranchDto(); var response = organizationBranchService.CreateOrganizationBranch(organizationBranch); // Assert Assert.IsNotNull(response); Assert.IsTrue(response.Result); Assert.IsFalse(response.Notifications.HasErrors()); Assert.IsInstanceOfType(response, typeof(GenericServiceResponse <bool>)); mockRepository.Verify(x => x.Insert(It.IsAny <OrganizationBranch>()), Times.Once); }