public async override Task Should_Success_ReadById() { string testName = GetCurrentMethod(); var dbContext = DbContext(testName); var serviceProvider = GetServiceProviderMock(dbContext).Object; GarmentShippingLocalSalesContractRepository repoSC = new GarmentShippingLocalSalesContractRepository(dbContext, serviceProvider); GarmentShippingLocalSalesContractDataUtil utilSC = new GarmentShippingLocalSalesContractDataUtil(repoSC); GarmentShippingLocalSalesContractModel dataSC = utilSC.GetModel(); var dataSalesContract = await repoSC.InsertAsync(dataSC); GarmentShippingLocalSalesNoteRepository repo = new GarmentShippingLocalSalesNoteRepository(dbContext, serviceProvider); GarmentShippingLocalSalesNoteDataUtil salesNoteDataUtil = new GarmentShippingLocalSalesNoteDataUtil(repo, utilSC); GarmentShippingLocalSalesNoteModel data = salesNoteDataUtil.GetModel(); data.LocalSalesContractId = dataSC.Id; var dataLocalSalesNote = await repo.InsertAsync(data); GarmentShippingLocalSalesDORepository repoLocalSalesDO = new GarmentShippingLocalSalesDORepository(dbContext, serviceProvider); GarmentShippingLocalSalesDODataUtil LocalSalesDODataUtil = new GarmentShippingLocalSalesDODataUtil(repoLocalSalesDO, salesNoteDataUtil); GarmentShippingLocalSalesDOModel dataLocalSalesDO = LocalSalesDODataUtil.GetModel(); dataLocalSalesDO.SetLocalSalesNoteId(data.Id, "test", "unitTest"); var result = await repoLocalSalesDO.InsertAsync(dataLocalSalesDO); var results = repoLocalSalesDO.ReadByIdAsync(dataLocalSalesDO.Id); Assert.NotNull(results); }
public async Task Should_Success_RejectShipping_Data() { string testName = GetCurrentMethod() + "Update"; var dbContext = DbContext(testName); var serviceProvider = GetServiceProviderMock(dbContext).Object; GarmentShippingLocalSalesContractRepository repoSC = new GarmentShippingLocalSalesContractRepository(dbContext, serviceProvider); GarmentShippingLocalSalesContractDataUtil utilSC = new GarmentShippingLocalSalesContractDataUtil(repoSC); GarmentShippingLocalSalesContractModel dataSC = utilSC.GetModel(); var dataSalesContract = await repoSC.InsertAsync(dataSC); GarmentShippingLocalSalesNoteRepository repo = new GarmentShippingLocalSalesNoteRepository(dbContext, serviceProvider); GarmentShippingLocalSalesNoteDataUtil salesNoteDataUtil = new GarmentShippingLocalSalesNoteDataUtil(repo, utilSC); GarmentShippingLocalSalesNoteModel oldModel = salesNoteDataUtil.GetModel(); oldModel.LocalSalesContractId = dataSC.Id; await repo.InsertAsync(oldModel); var model = repo.ReadAll().FirstOrDefault(); var data = await repo.ReadByIdAsync(model.Id); data.SetIsRejectedShipping(true, data.LastModifiedBy, data.LastModifiedAgent); data.SetRejectedReason("reject!", data.LastModifiedBy, data.LastModifiedAgent); var result = await repo.RejectShippingAsync(data.Id, data); Assert.NotEqual(0, result); }
public async override Task Should_Success_Update() { string testName = GetCurrentMethod(); var dbContext = DbContext(testName); var serviceProvider = GetServiceProviderMock(dbContext).Object; GarmentShippingLocalSalesContractRepository repoSC = new GarmentShippingLocalSalesContractRepository(dbContext, serviceProvider); GarmentShippingLocalSalesContractDataUtil utilSC = new GarmentShippingLocalSalesContractDataUtil(repoSC); GarmentShippingLocalSalesContractModel dataSC = utilSC.GetModel(); var dataSalesContract = await repoSC.InsertAsync(dataSC); GarmentShippingLocalSalesNoteRepository repo = new GarmentShippingLocalSalesNoteRepository(dbContext, serviceProvider); GarmentShippingLocalSalesNoteDataUtil salesNoteDataUtil = new GarmentShippingLocalSalesNoteDataUtil(repo, utilSC); GarmentShippingLocalSalesNoteModel data = salesNoteDataUtil.GetModel(); data.LocalSalesContractId = dataSC.Id; var dataLocalSalesNote = await repo.InsertAsync(data); GarmentShippingLocalSalesDORepository repoLocalSalesDO = new GarmentShippingLocalSalesDORepository(dbContext, serviceProvider); GarmentShippingLocalSalesDORepository repoLocalSalesDO2 = new GarmentShippingLocalSalesDORepository(dbContext, serviceProvider); GarmentShippingLocalSalesDODataUtil LocalSalesDODataUtil = new GarmentShippingLocalSalesDODataUtil(repoLocalSalesDO, salesNoteDataUtil); GarmentShippingLocalSalesDOModel oldModel = LocalSalesDODataUtil.GetModel(); oldModel.SetLocalSalesNoteId(data.Id, "test", "unitTest"); await repoLocalSalesDO.InsertAsync(oldModel); var model = repoLocalSalesDO.ReadAll().FirstOrDefault(); var modelToUpdate = await repoLocalSalesDO.ReadByIdAsync(model.Id); modelToUpdate.SetDate(oldModel.Date.AddDays(1), oldModel.LastModifiedBy, oldModel.LastModifiedAgent); modelToUpdate.SetTo("Updated " + oldModel.To, oldModel.LastModifiedBy, oldModel.LastModifiedAgent); modelToUpdate.SetStorageDivision("Updated " + oldModel.StorageDivision, oldModel.LastModifiedBy, oldModel.LastModifiedAgent); modelToUpdate.SetRemark("Updated " + oldModel.Remark, oldModel.LastModifiedBy, oldModel.LastModifiedAgent); foreach (var item in oldModel.Items) { item.SetDescription("Updated " + item.Description, item.LastModifiedBy, item.LastModifiedAgent); item.SetGrossWeight(1 + item.GrossWeight, item.LastModifiedBy, item.LastModifiedAgent); item.SetNettWeight(1 + item.NettWeight, item.LastModifiedBy, item.LastModifiedAgent); } GarmentShippingLocalSalesDOItemModel newItem = new GarmentShippingLocalSalesDOItemModel(2, 2, 2, "a", "", "", 2, 2, "", 2, 2, "", 2, 2); oldModel.Items.Add(newItem); var result = await repoLocalSalesDO2.UpdateAsync(modelToUpdate.Id, modelToUpdate); Assert.NotEqual(0, result); oldModel.Items.Remove(oldModel.Items.First()); var result2 = await repoLocalSalesDO2.UpdateAsync(oldModel.Id, oldModel); Assert.NotEqual(0, result2); }
public async Task Should_Success_Update_Data() { string testName = GetCurrentMethod() + "Update"; var dbContext = DbContext(testName); var serviceProvider = GetServiceProviderMock(dbContext).Object; GarmentShippingLocalSalesContractRepository repoSC = new GarmentShippingLocalSalesContractRepository(dbContext, serviceProvider); GarmentShippingLocalSalesContractDataUtil utilSC = new GarmentShippingLocalSalesContractDataUtil(repoSC); GarmentShippingLocalSalesContractModel dataSC = utilSC.GetModel(); var dataSalesContract = await repoSC.InsertAsync(dataSC); GarmentShippingLocalSalesNoteRepository repo = new GarmentShippingLocalSalesNoteRepository(dbContext, serviceProvider); GarmentShippingLocalSalesNoteDataUtil salesNoteDataUtil = new GarmentShippingLocalSalesNoteDataUtil(repo, utilSC); GarmentShippingLocalSalesNoteModel oldModel = salesNoteDataUtil.GetModel(); oldModel.LocalSalesContractId = dataSC.Id; await repo.InsertAsync(oldModel); var model = repo.ReadAll().FirstOrDefault(); var data = await repo.ReadByIdAsync(model.Id); data.SetDate(data.Date.AddDays(1), data.LastModifiedBy, data.LastModifiedAgent); data.SetTempo(model.Tempo + 1, data.LastModifiedBy, data.LastModifiedAgent); data.SetDispositionNo(model.DispositionNo + 1, data.LastModifiedBy, data.LastModifiedAgent); data.SetUseVat(!model.UseVat, data.LastModifiedBy, data.LastModifiedAgent); data.SetRemark(model.Remark + 1, data.LastModifiedBy, data.LastModifiedAgent); data.SetPaymentType(model.PaymentType + 1, data.LastModifiedBy, data.LastModifiedAgent); data.SetPaymentType(model.PaymentType + 1, data.LastModifiedBy, data.LastModifiedAgent); data.SetRejectedReason(null, data.LastModifiedBy, data.LastModifiedAgent); data.SetIsRejectedShipping(false, data.LastModifiedBy, data.LastModifiedAgent); data.SetIsRejectedFinance(false, data.LastModifiedBy, data.LastModifiedAgent); foreach (var item in data.Items) { item.SetProductId(item.ProductId + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetProductCode(item.ProductCode + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetProductName(item.ProductName + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetQuantity(item.Quantity + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetUomId(item.UomId + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetUomUnit(item.UomUnit + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetPrice(item.Price + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetPackageUomUnit(item.PackageUomUnit + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetPackageUomId(item.PackageUomId + 1, data.LastModifiedBy, data.LastModifiedAgent); item.SetPackageQuantity(item.PackageQuantity + 1, data.LastModifiedBy, data.LastModifiedAgent); } var result = await repo.UpdateAsync(data.Id, data); Assert.NotEqual(0, result); }
public async override Task Should_Success_Insert() { string testName = GetCurrentMethod(); var dbContext = DbContext(testName); var serviceProvider = GetServiceProviderMock(dbContext).Object; GarmentShippingLocalSalesContractRepository repoSC = new GarmentShippingLocalSalesContractRepository(dbContext, serviceProvider); GarmentShippingLocalSalesContractDataUtil utilSC = new GarmentShippingLocalSalesContractDataUtil(repoSC); GarmentShippingLocalSalesContractModel dataSC = utilSC.GetModel(); var dataSalesContract = await repoSC.InsertAsync(dataSC); GarmentShippingLocalSalesNoteRepository repo = new GarmentShippingLocalSalesNoteRepository(dbContext, serviceProvider); GarmentShippingLocalSalesNoteDataUtil salesNoteDataUtil = new GarmentShippingLocalSalesNoteDataUtil(repo, utilSC); GarmentShippingLocalSalesNoteModel data = salesNoteDataUtil.GetModel(); data.LocalSalesContractId = dataSC.Id; var result = await repo.InsertAsync(data); Assert.NotEqual(0, result); }
public GarmentShippingLocalSalesNoteDataUtil(GarmentShippingLocalSalesNoteRepository repository, GarmentShippingLocalSalesContractDataUtil dataUtilSC) : base(repository) { }