public void Should_Success_Get_All_Data()
        {
            var mockFacade = new Mock <IGarmentInternNoteFacade>();

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

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentInternNoteViewModel> >(It.IsAny <List <GarmentInternNote> >()))
            .Returns(new List <GarmentInternNoteViewModel> {
                ViewModel
            });
            mockMapper.Setup(x => x.Map <GarmentDeliveryOrderViewModel>(It.IsAny <GarmentDeliveryOrder>()))
            .Returns(new GarmentDeliveryOrderViewModel());
            mockMapper.Setup(x => x.Map <GarmentInvoiceViewModel>(It.IsAny <GarmentInvoice>()))
            .Returns(new GarmentInvoiceViewModel());

            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();

            IPOmockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(DeliveryOrderModel);

            var INVFacade = new Mock <IGarmentInvoice>();

            INVFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(garmentInvoiceModel);

            GarmentInternNoteController controller = GetController(mockFacade, IPOmockFacade, null, mockMapper, INVFacade);
            var response = controller.Get();

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

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

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentInternNoteViewModel>(It.IsAny <GarmentInternNote>()))
            .Returns(ViewModel);
            mockMapper.Setup(x => x.Map <GarmentDeliveryOrderViewModel>(It.IsAny <GarmentDeliveryOrder>()))
            .Returns(DeliveryOrderModelViewModel);
            mockMapper.Setup(x => x.Map <GarmentInvoiceViewModel>(It.IsAny <GarmentInvoice>()))
            .Returns(garmentInvoiceViewModel);

            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();

            IPOmockFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(DeliveryOrderModel);

            var INVFacade = new Mock <IGarmentInvoice>();

            INVFacade.Setup(x => x.ReadById(It.IsAny <int>()))
            .Returns(garmentInvoiceModel);

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

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
        public void Should_Error_Get_All_Data()
        {
            var mockFacade    = new Mock <IGarmentInternNoteFacade>();
            var mockMapper    = new Mock <IMapper>();
            var INVFacade     = new Mock <IGarmentInvoice>();
            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();
            GarmentInternNoteController controller = new GarmentInternNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, IPOmockFacade.Object, INVFacade.Object);
            var response = controller.Get();

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

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

            var mockMapper    = new Mock <IMapper>();
            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();
            var INVFacade     = new Mock <IGarmentInvoice>();

            GarmentInternNoteController controller = new GarmentInternNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, IPOmockFacade.Object, INVFacade.Object);
            var response = controller.Get(It.IsAny <int>());

            Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response));
        }
        public void Should_Error_Get_PDF_By_Id()
        {
            var validateMock = new Mock <IValidateService>();

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

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <GarmentInternNote>(It.IsAny <GarmentInternNoteViewModel>()))
            .Returns(Model);

            var mockFacade = new Mock <IGarmentInternNoteFacade>();

            mockFacade.Setup(x => x.Create(It.IsAny <GarmentInternNote>(), false, "unittestusername", 7))
            .ReturnsAsync(1);
            var IPOmockFacade = new Mock <IGarmentDeliveryOrderFacade>();

            var INVFacade = new Mock <IGarmentInvoice>();

            var user   = new Mock <ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

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

            GarmentInternNoteController controller = new GarmentInternNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object, IPOmockFacade.Object, INVFacade.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = user.Object
                }
            };

            controller.ControllerContext.HttpContext.Request.Headers["Accept"]            = "application/pdf";
            controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0";

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

            Assert.Equal(null, response.GetType().GetProperty("FileStream"));
        }