public void Should_Error_Get_All_Data_For_GarmentUnitExpenditureNote()
        {
            GarmentUnitDeliveryOrderControllers controller = new GarmentUnitDeliveryOrderControllers(GetServiceProvider().Object, null);
            var response = controller.GetForUnitExpenditureNote();

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Error_Get_All_Data_By_User()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            GarmentUnitDeliveryOrderControllers controller = new GarmentUnitDeliveryOrderControllers(GetServiceProvider().Object, mockFacade.Object);

            var response = controller.GetByUser();

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Error_Get_Data_By_Id()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(new GarmentUnitDeliveryOrder());

            GarmentUnitDeliveryOrderControllers controller = new GarmentUnitDeliveryOrderControllers(GetServiceProvider().Object, mockFacade.Object);

            var response = controller.Get(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Success_Get_All_Data_By_User()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacade.Setup(x => x.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), null, It.IsAny <string>()))
            .Returns(new ReadResponse <object>(new List <object>(), 1, new Dictionary <string, string>()));

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade);

            var response = controller.GetByUser();

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
        public async Task Should_Error_Create_Data()
        {
            var validateMock = new Mock <IValidateService>();

            validateMock.Setup(s => s.Validate(It.IsAny <GarmentUnitDeliveryOrderViewModel>())).Verifiable();

            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            GarmentUnitDeliveryOrderControllers controller = new GarmentUnitDeliveryOrderControllers(GetServiceProvider().Object, mockFacade.Object);

            var response = await controller.Post(this.ViewModel);

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Success_Get_All_Data_For_GarmentUnitExpenditureNote()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacade.Setup(x => x.ReadForUnitExpenditureNote(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), null, It.IsAny <string>()))
            .Returns(new ReadResponse <object>(new List <object>(), 0, new Dictionary <string, string>()));


            var mockMapper = new Mock <IMapper>();

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade, null, mockMapper);
            var response = controller.GetForUnitExpenditureNote();

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
Пример #7
0
        public void Should_Sucscess_Get_Data_By_Id()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrder>();

            mockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(Model);

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrderViewModel>(It.IsAny <GarmentUnitDeliveryOrder>()))
            .Returns(ViewModel);

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade, null, mockMapper);
            var response = controller.Get(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
        public void Should_Success_Get_Data_Item_By_Id()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacade.Setup(x => x.ReadForLeftOver(It.IsAny <string>()))
            .Returns(new List <object>());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrderViewModel>(It.IsAny <GarmentUnitDeliveryOrder>()))
            .Returns(new GarmentUnitDeliveryOrderViewModel());

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade, null, mockMapper);

            var response = controller.GetbyROleftover(It.IsAny <string>());

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
Пример #9
0
        public void Should_Success_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrder>();

            mockFacade.Setup(x => x.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), null, It.IsAny <string>()))
            .Returns(Tuple.Create(new List <GarmentUnitDeliveryOrder>(), 0, new Dictionary <string, string>()));

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentUnitDeliveryOrderViewModel> >(It.IsAny <List <GarmentUnitDeliveryOrder> >()))
            .Returns(new List <GarmentUnitDeliveryOrderViewModel> {
                ViewModel
            });

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade, null, mockMapper);
            var response = controller.Get();

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
        public void Should_Error_Get_Data_By_RO()
        {
            var mockFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacade.Setup(x => x.ReadForLeftOver(It.IsAny <string>()))
            .Throws(new Exception());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrderViewModel>(It.IsAny <GarmentUnitDeliveryOrder>()))
            .Returns(new GarmentUnitDeliveryOrderViewModel());

            GarmentUnitDeliveryOrderControllers controller = GetController(mockFacade, null, mockMapper);

            var response = controller.GetbyROleftover(It.IsAny <string>());


            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        private GarmentUnitDeliveryOrderControllers GetController(Mock <IGarmentUnitDeliveryOrderFacade> facadeMock, Mock <IValidateService> validateMock = null, Mock <IMapper> mapperMock = null)
        {
            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

            user.Setup(u => u.Claims).Returns(claims);

            var servicePMock = GetServiceProvider();

            if (validateMock != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IValidateService)))
                .Returns(validateMock.Object);
            }
            if (mapperMock != null)
            {
                servicePMock
                .Setup(x => x.GetService(typeof(IMapper)))
                .Returns(mapperMock.Object);
            }

            GarmentUnitDeliveryOrderControllers controller = new GarmentUnitDeliveryOrderControllers(servicePMock.Object, facadeMock.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                    {
                        User = user.Object
                    }
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["Authorization"] = "Bearer unittesttoken";
            controller.ControllerContext.HttpContext.Request.Path = new PathString("/v1/unit-test");
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "7";

            return(controller);
        }
Пример #12
0
        public void Should_Error_Update_Data()
        {
            var validateMock = new Mock <IValidateService>();

            validateMock.Setup(s => s.Validate(It.IsAny <GarmentUnitDeliveryOrderViewModel>())).Verifiable();

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrder>(It.IsAny <GarmentUnitDeliveryOrderViewModel>()))
            .Returns(Model);

            var mockFacade = new Mock <IGarmentUnitDeliveryOrder>();

            mockFacade.Setup(x => x.Create(It.IsAny <GarmentUnitDeliveryOrder>(), "unittestusername", 7))
            .ReturnsAsync(1);

            var controller = new GarmentUnitDeliveryOrderControllers(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object);

            var response = controller.Put(It.IsAny <int>(), It.IsAny <GarmentUnitDeliveryOrderViewModel>()).Result;

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }