Exemplo n.º 1
0
        public Task <int> InsertAsync(GarmentPackingListItemModel model)
        {
            model.FlagForCreate(_identityProvider.Username, USER_AGENT);

            _dbSet.Add(model);

            return(_dbContext.SaveChangesAsync());
        }
        public void GetReportData_Success()
        {
            var model  = 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, "", false, true, false, "");
            var model1 = new GarmentPackingListDetailSizeModel(1, "", 1);

            var model2 = new GarmentPackingListDetailModel(1, 1, "", "", 1, 1, 1, 1, 1, 1, 1, 1, 1, null, 1);

            var model3 = new GarmentPackingListItemModel("", "", 1, "", 1, "", "", "", 1, 1, "", 1, 1, 1, 1, 1, "", 1, "", "", "", "", "", "", "RO SAMPLE", null);

            var repoMock = new Mock <IGarmentPackingListRepository>();

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

            var repoMock3 = new Mock <IGarmentPackingListItemRepository>();

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

            var repoMock2 = new Mock <IGarmentPackingListDetailRepository>();

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

            var repoMock1 = new Mock <IGarmentPackingListDetailSizeRepository>();

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

            var httpMock = new Mock <IHttpClientService>();

            httpMock.Setup(s => s.SendAsync(HttpMethod.Get, It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));


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

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

            var service = GetService(spMock.Object);

            var result = service.GetReportData(model.InvoiceNo, model.PaymentTerm, DateTimeOffset.MinValue, DateTimeOffset.MaxValue, 0);

            Assert.NotEmpty(result.Data);
        }
Exemplo n.º 3
0
        public Task <int> UpdateAsync(int id, GarmentPackingListItemModel model)
        {
            var modelToUpdate = _dbSet
                                .FirstOrDefault(s => s.Id == id);

            modelToUpdate.SetAmount(model.Amount, _identityProvider.Username, USER_AGENT);

            return(_dbContext.SaveChangesAsync());
        }
        public void should_Success_Instantiate()
        {
            GarmentPackingListItemModel model = new GarmentPackingListItemModel();

            Assert.NotNull(model);
        }