public void Should_Success_Get_Data_By_Id()
        {
            var mockFacadeUnitDO = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockFacadeUnitDO.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(ModelUnitDO);
            var mockFacade = new Mock <IGarmentUnitExpenditureNoteFacade>();

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

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrderViewModel>(It.IsAny <GarmentUnitDeliveryOrder>()))
            .Returns(new GarmentUnitDeliveryOrderViewModel {
                Id    = It.IsAny <int>(),
                Items = new List <GarmentUnitDeliveryOrderItemViewModel>
                {
                    new GarmentUnitDeliveryOrderItemViewModel
                    {
                        Id          = It.IsAny <int>(),
                        DesignColor = "design"
                    }
                }
            });

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

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
Пример #2
0
 public void Should_Error_Get_All_Data()
 {
     var mockFacadeUnitDO = new Mock<IGarmentUnitDeliveryOrderFacade>();
     var mockFacade = new Mock<IGarmentUnitExpenditureNoteFacade>();
     var mockMapper = new Mock<IMapper>();
     GarmentUnitExpenditureNoteController controller = new GarmentUnitExpenditureNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, mockFacadeUnitDO.Object);
     var response = controller.Get();
     Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
 }
        private void Test_Get_PDF_By_Id()
        {
            var mockFacade = new Mock <IGarmentUnitExpenditureNoteFacade>();

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

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentUnitExpenditureNoteViewModel>(It.IsAny <GarmentUnitExpenditureNote>()))
            .Returns(ViewModel);

            var serviceProvider = GetServiceProvider();

            var garmentUnitDeliveryOrder = new GarmentUnitDeliveryOrder
            {
                Id       = It.IsAny <int>(),
                UnitDONo = "unitdono",
                Article  = "Article12345",
                RONo     = "RONo12345",
                Items    = new List <GarmentUnitDeliveryOrderItem>
                {
                    new GarmentUnitDeliveryOrderItem
                    {
                        Id   = It.IsAny <int>(),
                        RONo = "RONO",
                    }
                }
            };

            var mockGarmentUnitDeliveryOrderFacade = new Mock <IGarmentUnitDeliveryOrderFacade>();

            mockGarmentUnitDeliveryOrderFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(garmentUnitDeliveryOrder);

            mockMapper.Setup(x => x.Map <GarmentUnitDeliveryOrderViewModel>(It.IsAny <GarmentUnitDeliveryOrder>()))
            .Returns(new GarmentUnitDeliveryOrderViewModel {
                Id    = It.IsAny <int>(),
                Items = new List <GarmentUnitDeliveryOrderItemViewModel>
                {
                    new GarmentUnitDeliveryOrderItemViewModel
                    {
                        Id = It.IsAny <int>()
                    }
                }
            });

            GarmentUnitExpenditureNoteController controller = GetController(mockFacade, mockGarmentUnitDeliveryOrderFacade, null, mockMapper);

            controller.ControllerContext.HttpContext.Request.Headers["Accept"] = "application/pdf";

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

            Assert.NotNull(response.GetType().GetProperty("FileStream"));
        }
Пример #4
0
        public void Should_Error_Get_Data_By_Id()
        {
            var mockFacade = new Mock<IGarmentUnitExpenditureNoteFacade>();
            mockFacade.Setup(x => x.ReadById(It.IsAny<int>()))
                .Returns((GarmentUnitExpenditureNoteViewModel)null);
            var mockFacadeUnitDO = new Mock<IGarmentUnitDeliveryOrderFacade>();

            var mockMapper = new Mock<IMapper>();

            GarmentUnitExpenditureNoteController controller = GetController(mockFacade, mockFacadeUnitDO, null, mockMapper);
            var response = controller.Get(It.IsAny<int>());
            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
Пример #5
0
        public void Should_Success_Get_All_Data()
        {
            var mockFacade = new Mock<IGarmentUnitExpenditureNoteFacade>();
            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>(), 0, new Dictionary<string, string>()));
            var mockFacadeUnitDO = new Mock<IGarmentUnitDeliveryOrderFacade>();

            var mockMapper = new Mock<IMapper>();
            mockMapper.Setup(x => x.Map<List<GarmentUnitExpenditureNoteViewModel>>(It.IsAny<List<GarmentUnitExpenditureNote>>()))
                .Returns(new List<GarmentUnitExpenditureNoteViewModel> { ViewModel });

            GarmentUnitExpenditureNoteController controller = GetController(mockFacade, mockFacadeUnitDO, null, mockMapper);
            var response = controller.Get();
            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }