public async Task <GarmentUnitReceiptNote> GetTestData() { var data = GetNewData(); await facade.Create(data); return(data); }
public async Task Should_Success_Create_Data_GUDANG_SISA() { var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = await dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); data.URNType = "GUDANG SISA"; data.ExpenditureId = 1; data.ExpenditureNo = "no"; data.Category = "FABRIC"; var Response = await facade.Create(data); Assert.NotEqual(0, Response); //var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data1 = await dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); data1.StorageId = data.StorageId; data1.Items.First().UomId = data.Items.First().UomId; data1.UnitId = data.UnitId; data.URNType = "GUDANG SISA"; data.ExpenditureId = 1; data.ExpenditureNo = "no"; data.Category = "ACCESSORIES"; var Response1 = await facade.Create(data1); Assert.NotEqual(0, Response1); }
public async Task <GarmentUnitReceiptNote> GetTestData(long?ticks = null) { var data = await GetNewData(ticks); await facade.Create(data); return(data); }
public async void Should_Success_Create_Data() { var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); var Response = await facade.Create(data); Assert.NotEqual(Response, 0); }
public async Task Should_Error_Create_Data_Null_Items() { var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = await dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); data.Items = null; Exception e = await Assert.ThrowsAsync <Exception>(async() => await facade.Create(data)); Assert.NotNull(e.Message); }
public async Task Should_Success_Create_Data() { var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = await dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); var Response = await facade.Create(data); Assert.NotEqual(Response, 0); //var facade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data1 = await dataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); data1.StorageId = data.StorageId; data1.Items.First().UomId = data.Items.First().UomId; data1.UnitId = data.UnitId; var Response1 = await facade.Create(data1); Assert.NotEqual(Response1, 0); }
public async void Should_Success_Get_Report_Excel() { GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = dataUtilDO(facade, GetCurrentMethod()).GetNewData(); await facade.Create(data, USERNAME); var uFacade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var datas = dataUtil(uFacade, GetCurrentMethod()).GetNewDataWithStorage(); var Responses = await uFacade.Create(datas); Assert.NotEqual(Responses, 0); var Facade = new MonitoringUnitReceiptAllFacade(ServiceProvider, _dbContext(GetCurrentMethod())); var Response = Facade.GetReport(null, null, null, null, null, null, null, null, 1, 25, "{}", 7); Assert.NotEqual(Response.Item2, 0); var Response1 = Facade.GenerateExcel(null, null, null, null, null, null, null, null, 1, 25, "{}", 7); Assert.IsType(typeof(System.IO.MemoryStream), Response1); }
public async Task Should_Success_Get_Report_Data() { GarmentDeliveryOrderFacade facade = new GarmentDeliveryOrderFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var data = await dataUtilDO(facade, GetCurrentMethod()).GetNewData(); await facade.Create(data, USERNAME); var uFacade = new GarmentUnitReceiptNoteFacade(GetServiceProvider(), _dbContext(GetCurrentMethod())); var datas = await dataUtil(uFacade, GetCurrentMethod()).GetNewDataWithStorage(); var Responses = await uFacade.Create(datas); Assert.NotEqual(Responses, 0); var Facade = new MonitoringUnitReceiptAllFacade(ServiceProvider, _dbContext(GetCurrentMethod())); var Response = Facade.GetReport(null, null, null, null, null, null, null, null, 1, 25, "{}", 7); Assert.NotEqual(Response.Item2, 0); var Response1 = Facade.GetReport(null, null, null, null, null, null, null, null, 1, 25, "{}", 7); Assert.NotNull(Response1.Item1); }
public async Task Should_Success_Delete_Data_Proses() { var facade1 = new GarmentUnitDeliveryOrderFacade(_dbContext(GetCurrentMethod()), GetServiceProvider().Object); var data1 = await UnitDOdataUtil(facade1, GetCurrentMethod()).GetTestDataMultipleItemForURNProcess(); HttpResponseMessage httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK); httpResponseMessage.Content = new StringContent("{\"apiVersion\":\"1.0\",\"statusCode\":200,\"message\":\"Ok\",\"data\":[{\"Id\":7,\"code\":\"USD\",\"rate\":13700.0,\"date\":\"2018/10/20\"}],\"info\":{\"count\":1,\"page\":1,\"size\":1,\"total\":2,\"order\":{\"date\":\"desc\"},\"select\":[\"Id\",\"code\",\"rate\",\"date\"]}}"); var httpClientService = new Mock <IHttpClientService>(); httpClientService .Setup(x => x.GetAsync(It.IsAny <string>())) .ReturnsAsync(httpResponseMessage); httpClientService .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("master/garment-suppliers")))) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(new SupplierDataUtil().GetResultFormatterOkString()) }); httpClientService .Setup(x => x.GetAsync(It.Is <string>(s => s.Contains("delivery-returns")))) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(new GarmentDeliveryReturnDataUtil().GetResultFormatterOkString(data1)) }); httpClientService .Setup(x => x.PutAsync(It.Is <string>(s => s.Contains("delivery-returns")), It.IsAny <HttpContent>())) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(new GarmentDeliveryReturnDataUtil().GetResultFormatterOkString()) }); var mapper = new Mock <IMapper>(); mapper .Setup(x => x.Map <GarmentUnitReceiptNoteViewModel>(It.IsAny <GarmentUnitReceiptNote>())) .Returns(new GarmentUnitReceiptNoteViewModel { Id = 1, DOId = 1, DOCurrency = new CurrencyViewModel(), Supplier = new SupplierViewModel(), Unit = new UnitViewModel(), Items = new List <GarmentUnitReceiptNoteItemViewModel> { new GarmentUnitReceiptNoteItemViewModel { Product = new GarmentProductViewModel(), Uom = new UomViewModel() } } }); var mockGarmentDeliveryOrderFacade = new Mock <IGarmentDeliveryOrderFacade>(); mockGarmentDeliveryOrderFacade .Setup(x => x.ReadById(It.IsAny <int>())) .Returns(new GarmentDeliveryOrder()); var serviceProviderMock = new Mock <IServiceProvider>(); serviceProviderMock .Setup(x => x.GetService(typeof(IdentityService))) .Returns(new IdentityService { Username = "******" }); serviceProviderMock .Setup(x => x.GetService(typeof(IHttpClientService))) .Returns(httpClientService.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IMapper))) .Returns(mapper.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IGarmentDeliveryOrderFacade))) .Returns(mockGarmentDeliveryOrderFacade.Object); serviceProviderMock .Setup(x => x.GetService(typeof(IdentityService))) .Returns(new IdentityService() { Token = "Token", Username = "******" }); var facade = new GarmentUnitReceiptNoteFacade(serviceProviderMock.Object, _dbContext(GetCurrentMethod())); var data = await garmentUnitReceiptNoteDataUtil(facade, GetCurrentMethod()).GetNewDataWithStorage(); data.URNType = "PROSES"; await facade.Create(data); var Response = await facade.Delete((int)data.Id, (string)data.DeletedReason); Assert.NotEqual(0, Response); }