コード例 #1
0
        public void Should_Error_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();
            var mockMapper = new Mock <IMapper>();
            GarmentCorrectionNotePriceController controller = new GarmentCorrectionNotePriceController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object);
            var response = controller.Get();

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
コード例 #2
0
        private GarmentCorrectionNotePriceController GetController(Mock <IGarmentCorrectionNotePriceFacade> facadeM, Mock <IValidateService> validateM, Mock <IMapper> mapper, Mock <IGarmentDeliveryOrderFacade> garmentDeliveryOrderFacadeM = null, Mock <IGarmentInternalPurchaseOrderFacade> garmentInternalPurchaseOrderFacadeM = null, Mock <IGarmentInvoice> garmentInvoiceMock = null)
        {
            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

            user.Setup(u => u.Claims).Returns(claims);

            var servicePMock = GetServiceProvider();

            if (validateM != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IValidateService)))
                .Returns(validateM.Object);
            }

            if (garmentDeliveryOrderFacadeM != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IGarmentDeliveryOrderFacade)))
                .Returns(garmentDeliveryOrderFacadeM.Object);
            }

            if (garmentInternalPurchaseOrderFacadeM != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IGarmentInternalPurchaseOrderFacade)))
                .Returns(garmentInternalPurchaseOrderFacadeM.Object);
            }

            if (garmentInvoiceMock != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IGarmentInvoice)))
                .Returns(garmentInvoiceMock.Object);
            }

            var controller = new GarmentCorrectionNotePriceController(servicePMock.Object, mapper.Object, facadeM.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = user.Object
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["Authorization"] = "Bearer unittesttoken";
            controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "7";

            return(controller);
        }
コード例 #3
0
        public async Task Should_Error_Create_Data()
        {
            var mockMapper = new Mock <IMapper>();
            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            var controller = new GarmentCorrectionNotePriceController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object);

            var response = await controller.Post(new GarmentCorrectionNoteViewModel());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
コード例 #4
0
        private void Get_Ppn_PDF_By_Id_NullInvoice(string correctionType)
        {
            var Model = this.Model;

            Model.CorrectionType = correctionType;

            var ViewModel = this.ViewModel;

            ViewModel.UseVat = true;

            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>()))
            .Returns(ViewModel);

            var garmentdeliveryOrder = new GarmentDeliveryOrder
            {
                DOCurrencyRate = 1,
                Items          = new List <GarmentDeliveryOrderItem>
                {
                    new GarmentDeliveryOrderItem
                    {
                        Details = Model.Items.Select(i => new GarmentDeliveryOrderDetail
                        {
                            Id = i.DODetailId
                        }).ToList()
                    }
                }
            };

            var mockGarmentDeliveryOrderFacade = new Mock <IGarmentDeliveryOrderFacade>();

            mockGarmentDeliveryOrderFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(garmentdeliveryOrder);

            var mockGarmentInvoiceFacade = new Mock <IGarmentInvoice>();

            mockGarmentInvoiceFacade.Setup(x => x.ReadByDOId(1))
            .Returns(new GarmentInvoice());

            GarmentCorrectionNotePriceController controller = GetController(mockFacade, null, mockMapper, mockGarmentDeliveryOrderFacade, null, mockGarmentInvoiceFacade);

            controller.ControllerContext.HttpContext.Request.Headers["Accept"] = "application/pdf";

            var response = controller.GetReturnNotePpn(It.IsAny <int>());

            Assert.NotNull(response.GetType().GetProperty("FileStream"));
        }
コード例 #5
0
        public void Should_Error_Get_Pph_Data_By_Id()
        {
            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            GarmentCorrectionNotePriceController controller = new GarmentCorrectionNotePriceController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object);
            var response = controller.GetReturnNotePph(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
コード例 #6
0
        public void Should_Success_Get_Data_By_Id()
        {
            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>()))
            .Returns(ViewModel);

            GarmentCorrectionNotePriceController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.Get(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
コード例 #7
0
        public void Should_Success_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), null, It.IsAny <string>()))
            .Returns(Tuple.Create(new List <GarmentCorrectionNote>(), 0, new Dictionary <string, string>()));

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentCorrectionNoteViewModel> >(It.IsAny <List <GarmentCorrectionNote> >()))
            .Returns(new List <GarmentCorrectionNoteViewModel> {
                ViewModel
            });

            GarmentCorrectionNotePriceController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.Get();

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
コード例 #8
0
        public void Should_Error_Get_Pph_Data_Invalid_By_Id()
        {
            var ViewModel = this.ViewModel;

            ViewModel.UseIncomeTax = false;

            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>()))
            .Returns(ViewModel);

            GarmentCorrectionNotePriceController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.GetReturnNotePph(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
コード例 #9
0
        private void Test_Get_PDF_By_Id(string correctionType)
        {
            var Model = this.Model;

            Model.CorrectionType = correctionType;

            var mockFacade = new Mock <IGarmentCorrectionNotePriceFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>()))
            .Returns(ViewModel);

            var mockGarmentDeliveryOrderFacade = new Mock <IGarmentDeliveryOrderFacade>();

            mockGarmentDeliveryOrderFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(new GarmentDeliveryOrder {
                DOCurrencyRate = 1
            });

            var mockGarmentInternalPurchaseOrderFacade = new Mock <IGarmentInternalPurchaseOrderFacade>();

            mockGarmentInternalPurchaseOrderFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(new GarmentInternalPurchaseOrder {
                UnitCode = "UnitCode"
            });

            GarmentCorrectionNotePriceController controller = GetController(mockFacade, null, mockMapper, mockGarmentDeliveryOrderFacade, mockGarmentInternalPurchaseOrderFacade);

            controller.ControllerContext.HttpContext.Request.Headers["Accept"] = "application/pdf";

            var response = controller.Get(It.IsAny <int>());

            Assert.NotNull(response.GetType().GetProperty("FileStream"));
        }