Ejemplo n.º 1
0
        public void Should_Success_GeneratePdf()
        {
            Mock <IGarmentPurchaseRequestFacade> garmentPurchaseRequestFacade = new Mock <IGarmentPurchaseRequestFacade>();

            garmentPurchaseRequestFacade
            .Setup(x => x.GetGarmentPreSalesContract(It.IsAny <long>()))
            .Returns(new GarmentPreSalesContractViewModel());

            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            serviceProvider
            .Setup(x => x.GetService(typeof(IGarmentPurchaseRequestFacade)))
            .Returns(garmentPurchaseRequestFacade.Object);

            serviceProvider
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******"
            });

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var Response = facade.GeneratePdf(new GarmentPurchaseRequestViewModel
            {
                Buyer = new BuyerViewModel(),
                Items = new List <GarmentPurchaseRequestItemViewModel>
                {
                    new GarmentPurchaseRequestItemViewModel
                    {
                        UId                          = null,
                        Category                     = new CategoryViewModel(),
                        Product                      = new ProductViewModel(),
                        Uom                          = new UomViewModel(),
                        Status                       = null,
                        IsUsed                       = false,
                        PriceUom                     = new UomViewModel(),
                        Quantity                     = 5,
                        BudgetPrice                  = 2,
                        PriceConversion              = 1,
                        IsOpenPO                     = false,
                        OpenPOBy                     = null,
                        OpenPODate                   = DateTimeOffset.MinValue,
                        IsApprovedOpenPOMD           = false,
                        ApprovedOpenPOMDBy           = null,
                        ApprovedOpenPOMDDate         = DateTimeOffset.MinValue,
                        IsApprovedOpenPOPurchasing   = false,
                        ApprovedOpenPOPurchasingBy   = null,
                        ApprovedOpenPOPurchasingDate = DateTimeOffset.MinValue,
                        IsApprovedOpenPOKadivMd      = false,
                        ApprovedOpenPOKadivMdBy      = null,
                        ApprovedOpenPOKadivMdDate    = DateTimeOffset.MinValue,
                    }
                }
            });

            Assert.IsType <MemoryStream>(Response);
        }
Ejemplo n.º 2
0
        public void Should_Success_GeneratePdf()
        {
            Mock <IGarmentPurchaseRequestFacade> garmentPurchaseRequestFacade = new Mock <IGarmentPurchaseRequestFacade>();

            garmentPurchaseRequestFacade
            .Setup(x => x.GetGarmentPreSalesContract(It.IsAny <long>()))
            .Returns(new GarmentPreSalesContractViewModel());

            Mock <IServiceProvider> serviceProvider = new Mock <IServiceProvider>();

            serviceProvider
            .Setup(x => x.GetService(typeof(IGarmentPurchaseRequestFacade)))
            .Returns(garmentPurchaseRequestFacade.Object);

            serviceProvider
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(new IdentityService()
            {
                Token = "Token", Username = "******"
            });

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(serviceProvider.Object, _dbContext(GetCurrentMethod()));
            var Response = facade.GeneratePdf(new GarmentPurchaseRequestViewModel
            {
                Buyer = new BuyerViewModel(),
                Items = new List <GarmentPurchaseRequestItemViewModel>
                {
                    new GarmentPurchaseRequestItemViewModel
                    {
                        Category        = new CategoryViewModel(),
                        Product         = new ProductViewModel(),
                        Uom             = new UomViewModel(),
                        PriceUom        = new UomViewModel(),
                        Quantity        = 5,
                        BudgetPrice     = 2,
                        PriceConversion = 1
                    }
                }
            });

            Assert.IsType <MemoryStream>(Response);
        }