public static bool Validate(this DepartmentBo department, ILocalizedMessageProvider localizedMessageProvider, out PackagingSlipGenerationResponse response)
        {
            response = null;

            if (department == null)
            {
                response = new PackagingSlipGenerationResponse
                {
                    ErrorMessage = localizedMessageProvider.GetDepartmentNotProvidedMessage,
                    PackagingSlipGenerationResponseType = PackagingSlipGenerationResponseType.Failure
                };

                return(false);
            }

            if (department.DepartmentType != DepartmentType.Royality)
            {
                response = new PackagingSlipGenerationResponse
                {
                    ErrorMessage = localizedMessageProvider.GetDepartmentNotRoyalityMessage,
                    PackagingSlipGenerationResponseType = PackagingSlipGenerationResponseType.Failure
                };

                return(false);
            }

            return(true);
        }
예제 #2
0
        public static bool Validate(this Department department, out PackagingSlipGenerationResponse response)
        {
            response = null;

            if (department == null)
            {
                response = new PackagingSlipGenerationResponse
                {
                    ErrorMessage = Resources.DepartmentNotProvided,
                    PackagingSlipGenerationResponseType = PackagingSlipGenerationResponseType.Failure
                };

                return(false);
            }

            if (department.DepartmentType != DepartmentType.Royality)
            {
                response = new PackagingSlipGenerationResponse
                {
                    ErrorMessage = Resources.DepartmentNotRoyality,
                    PackagingSlipGenerationResponseType = PackagingSlipGenerationResponseType.Failure
                };

                return(false);
            }

            return(true);
        }
        public void HandleBookPayment_Failure()
        {
            // Arrange
            var packagingSlipServiceResponse = new PackagingSlipGenerationResponse
            {
                PackagingSlipGenerationResponseType = PackagingSlipGenerationResponseType.Failure
            };

            packagingSlipServiceMock.Setup(c => c.GenerateDuplicateSlip(It.IsAny <Department>())).Returns(packagingSlipServiceResponse);

            var payment = CreatePayment();

            var target = new BookPaymentFacade(packagingSlipServiceMock.Object, commissionServiceMock.Object, agentServiceMock.Object);

            // Act
            var result = target.HandleBookPayment(payment);

            // Assert
            Assert.AreEqual(PaymentResponseType.Failure, result.PaymentResponseType);
            packagingSlipServiceMock.Verify(c => c.GenerateDuplicateSlip(It.IsAny <Department>()), Times.Once);
            commissionServiceMock.Verify(c => c.Calculate(It.IsAny <double>()), Times.Never);
        }