Exemple #1
0
        public async Task Should_Success_Create_Data_Master()
        {
            var mockHttpClient = new Mock <IHttpClientService>();

            mockHttpClient
            .Setup(x => x.PatchAsync(It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK));

            var mockServiceProvider = GetServiceProvider();

            mockServiceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(mockHttpClient.Object);

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(mockServiceProvider.Object, _dbContext(GetCurrentMethod()));
            var model = dataUtil(facade, GetCurrentMethod()).GetNewData();

            model.PRType = "MASTER";
            model.RONo   = null;
            foreach (var item in model.Items)
            {
                item.PO_SerialNumber = null;
            }
            var Response = await facade.Create(model, USERNAME);

            Assert.NotEqual(Response, 0);
        }
Exemple #2
0
        public async Task Should_Error_Create_Data_Update_IsPR()
        {
            var mockHttpClient = new Mock <IHttpClientService>();

            mockHttpClient
            .Setup(x => x.PatchAsync(It.IsAny <string>(), It.IsAny <HttpContent>()))
            .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.InternalServerError)
            {
                Content = new StringContent("")
            });

            var mockServiceProvider = GetServiceProvider();

            mockServiceProvider
            .Setup(x => x.GetService(typeof(IHttpClientService)))
            .Returns(mockHttpClient.Object);

            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(mockServiceProvider.Object, _dbContext(GetCurrentMethod()));
            var model = dataUtil(facade, GetCurrentMethod()).GetNewData();

            model.PRType   = "SAMPLE";
            model.UnitCode = "C2A";
            model.RONo     = null;
            foreach (var item in model.Items)
            {
                item.CategoryName    = "FABRIC";
                item.PO_SerialNumber = null;
            }
            Exception e = await Assert.ThrowsAsync <Exception>(async() => await facade.Create(model, USERNAME));

            Assert.NotNull(e.Message);
        }
        public async Task <GarmentPurchaseRequest> GetTestData(GarmentPurchaseRequest data = null)
        {
            data = data ?? GetNewData();
            await facade.Create(data, "Unit Test");

            return(data);
        }
Exemple #4
0
        public async Task <GarmentPurchaseRequest> GetTestData()
        {
            var data = GetNewData();
            await facade.Create(data, "Unit Test");

            return(data);
        }
Exemple #5
0
        public async Task Should_Success_Create_Data()
        {
            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(ServiceProvider, _dbContext(GetCurrentMethod()));
            var model    = dataUtil(facade, GetCurrentMethod()).GetNewData();
            var Response = await facade.Create(model, USERNAME);

            Assert.NotEqual(Response, 0);
        }
Exemple #6
0
        public async Task Should_Success_Get_Data_By_Name()
        {
            var facade    = new GarmentPurchaseRequestFacade(ServiceProvider, _dbContext(GetCurrentMethod()));
            var data      = dataUtil(facade, GetCurrentMethod()).GetNewData();
            var Responses = await facade.Create(data, USERNAME);

            var Response = facade.ReadName(data.CreatedBy);

            Assert.NotNull(Response);
        }
Exemple #7
0
        public async Task Should_Error_Create_Data()
        {
            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(ServiceProvider, _dbContext(GetCurrentMethod()));
            var model = dataUtil(facade, GetCurrentMethod()).GetNewData();

            model.Items = null;
            Exception e = await Assert.ThrowsAsync <Exception>(async() => await facade.Create(model, USERNAME));

            Assert.NotNull(e.Message);
        }
Exemple #8
0
        public async Task Should_Success_Create_Data_Master()
        {
            GarmentPurchaseRequestFacade facade = new GarmentPurchaseRequestFacade(_dbContext(GetCurrentMethod()));
            var model = dataUtil(facade, GetCurrentMethod()).GetNewData();

            model.PRType = "MASTER";
            model.RONo   = null;
            foreach (var item in model.Items)
            {
                item.PO_SerialNumber = null;
            }
            var Response = await facade.Create(model, USERNAME);

            Assert.NotEqual(Response, 0);
        }