public void should_Success_Instantiate()
        {
            GarmentShippingInvoiceItemModel model = new GarmentShippingInvoiceItemModel("ro", "scno", 1, "buyerbrandname", 1, 1, "comocode", "comoname", "comodesc", "comodesc", "comodesc", "comodesc", 1, "pcs", 10, 10, 100, "usd", 1, "unitcode", 3, 1);

            Assert.Equal(1, model.PackingListItemId);
            Assert.NotNull(model);
        }
        public Task <int> InsertAsync(GarmentShippingInvoiceItemModel model)
        {
            model.FlagForCreate(_identityProvider.Username, USER_AGENT);

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
        public void GetReportData_Success()
        {
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", null, 1, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };
            var model1 = new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "comodesc", "comodesc", "comodesc", 1, "", 1, 1, 1, "", 1, "C10", 1, 1)
            {
                GarmentShippingInvoiceId = 1
            };

            var model2 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, true, true, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", true, true, 1, "", GarmentPackingListStatusEnum.CREATED, "", true, "", true, true, true, "")
            {
                Id = 1
            };

            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceItemModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentPackingListRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model2
            }.AsQueryable());

            var service = GetService(GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object).Object);

            var result = service.GetReportData(model1.UnitCode, DateTime.MinValue, DateTime.Now, 0);

            Assert.NotEmpty(result.ToList());
        }
        public Task <int> UpdateAsync(int id, GarmentShippingInvoiceItemModel model)
        {
            var modelToUpdate = _dbSet
                                .FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetCMTPrice(model.CMTPrice, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetComodityDesc(model.ComodityDesc, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetPrice(model.Price, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetUomId(model.UomId, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetUomUnit(model.UomUnit, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetDesc2(model.Desc2, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetDesc3(model.Desc3, _identityProvider.Username, USER_AGENT);
            modelToUpdate.SetDesc4(model.Desc4, _identityProvider.Username, USER_AGENT);


            return(_dbContext.SaveChangesAsync());
        }
        public void GetReportData_Success()
        {
            var model = new GarmentShippingInvoiceModel(1, "", DateTimeOffset.Now, "", "", 1, "A99", "", "", "", "", 1, "", "", DateTimeOffset.Now, "", 1, "", 1, "", 1, "", 1, "", DateTimeOffset.Now,
                                                        "", DateTimeOffset.Now, "", "", null, 1, "", "", "", false, "", DateTimeOffset.Now, "", DateTimeOffset.Now, "", DateTimeOffset.Now, null, 1, "", "", null)
            {
                Id = 1
            };

            var model1 = new GarmentPackingListModel("", "", "DL", 1, "", DateTimeOffset.Now, "", "", DateTimeOffset.Now, "", 1, "", "", "", "", "", DateTimeOffset.Now, DateTimeOffset.Now, DateTimeOffset.Now, false, false, "", "", "", null, 1, 1, 1, 1, null, "", "", "", "", "", "", "", false, false, 1, "", GarmentPackingListStatusEnum.CREATED, "", false, "")
            {
                Id = 1
            };

            var model2 = new GarmentShippingCreditAdviceModel(1, 1, "", DateTimeOffset.Now, 1, 1, "", "", "", true, "", 1, 1, "", DateTimeOffset.Now, DateTimeOffset.Now, "", 1, 1, 1, DateTimeOffset.Now, 1, 1, 1, 1, 1, 1, 1, "", 1, "", "", 1, "", "", 1, 1, 1, DateTimeOffset.Now, "", DateTimeOffset.Now, 1, "", DateTimeOffset.Now, 1, DateTimeOffset.Now, "");


            var model3 = new GarmentShippingInvoiceItemModel("", "", 1, "", 1, 1, "", "", "", "comodesc", "comodesc", "comodesc", 1, "", 1, 1, 1, "", 1, "C10", 1, 1)
            {
                GarmentShippingInvoiceId = 1
            };


            var repoMock = new Mock <IGarmentShippingInvoiceRepository>();

            repoMock.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceModel>()
            {
                model
            }.AsQueryable());

            var repoMock1 = new Mock <IGarmentPackingListRepository>();

            repoMock1.Setup(s => s.ReadAll())
            .Returns(new List <GarmentPackingListModel>()
            {
                model1
            }.AsQueryable());

            var repoMock2 = new Mock <IGarmentShippingCreditAdviceRepository>();

            repoMock2.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingCreditAdviceModel>()
            {
                model2
            }.AsQueryable());


            var repoMock3 = new Mock <IGarmentShippingInvoiceItemRepository>();

            repoMock3.Setup(s => s.ReadAll())
            .Returns(new List <GarmentShippingInvoiceItemModel>()
            {
                model3
            }.AsQueryable());


            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(JsonConvert.SerializeObject(new { data = new List <GarmentCurrency> {
                                                                                  new GarmentCurrency()
                                                                                  {
                                                                                      code = "usd"
                                                                                  }
                                                                              } }))
            });

            var spMock = GetServiceProvider(repoMock.Object, repoMock1.Object, repoMock2.Object, repoMock3.Object);

            spMock.Setup(s => s.GetService(typeof(IHttpClientService)))
            .Returns(httpMock.Object);
            var service = GetService(spMock.Object);

            var result = service.GetReportData(model.BuyerAgentCode, DateTime.MinValue, DateTime.MaxValue, 0);

            Assert.NotEmpty(result.Data);
        }