Ejemplo n.º 1
0
        public async Task <GarmentInvoicePaymentModel> GetTestData()
        {
            GarmentInvoicePaymentModel model = GetNewData();
            await Service.CreateAsync(model);

            return(await Service.ReadByIdAsync(model.Id));
        }
        public async Task Should_Success_Get_Data_By_Id()
        {
            GarmentInvoicePaymentService service = new GarmentInvoicePaymentService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));
            GarmentInvoicePaymentModel   model   = await _dataUtil(service, GetCurrentMethod()).GetTestData();

            var Response = await service.ReadByIdAsync(model.Id);

            Assert.NotNull(Response);
        }
        public async Task Should_Success_Update_Data()
        {
            GarmentInvoicePaymentService service = new GarmentInvoicePaymentService(GetServiceProvider().Object, _dbContext(GetCurrentMethod()));


            GarmentInvoicePaymentModel model = await _dataUtil(service, GetCurrentMethod()).GetTestData();

            var newModel = await service.ReadByIdAsync(model.Id);

            //newModel.BGCheckNumber = "newBG";
            var Response1 = await service.UpdateAsync(newModel.Id, newModel);

            Assert.NotEqual(0, Response1);

            GarmentInvoicePaymentModel model2 = await _dataUtil(service, GetCurrentMethod()).GetTestData();

            //var newModel2 = await service.ReadByIdAsync(model.Id);
            GarmentInvoicePaymentModel newModel2 = new GarmentInvoicePaymentModel();

            newModel2.Id = model2.Id;

            newModel2.Items = new List <GarmentInvoicePaymentItemModel> {
                model2.Items.First()
            };
            var Response = await service.UpdateAsync(model2.Id, newModel2);

            Assert.NotEqual(0, Response);

            GarmentInvoicePaymentItemModel newItem = new GarmentInvoicePaymentItemModel
            {
                InvoiceId = 3,
                InvoiceNo = "no3",
                Amount    = 3,
                IDRAmount = 3
            };

            newModel2.Items.Add(newItem);
            var Response3 = await service.UpdateAsync(model2.Id, newModel2);

            Assert.NotEqual(0, Response);
        }