public void Should_Success_Get_Report_Trace_IN()
        {
            var mockFacade = new Mock <ITraceableBeacukaiFacade>();

            mockFacade.Setup(x => x.GetReportTraceableIN(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Tuple.Create(new List <TraceableInBeacukaiViewModel> {
            }, 25));


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

            user.Setup(u => u.Claims).Returns(claims);
            TraceableBeacukaiController controller = new TraceableBeacukaiController(mockFacade.Object, GetServiceProvider().Object);

            controller.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";

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

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
        private TraceableBeacukaiController GetController(Mock <ITraceableBeacukaiFacade> facadeM)
        {
            var user   = new Mock <System.Security.Claims.ClaimsPrincipal>();
            var claims = new Claim[]
            {
                new Claim("username", "unittestusername")
            };

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

            var servicePMock = GetServiceProvider();

            var controller = new TraceableBeacukaiController(facadeM.Object, servicePMock.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);
        }
        public void Should_Success_Get_Xls_Trace_Out()
        {
            var mockFacade = new Mock <ITraceableBeacukaiFacade>();

            mockFacade.Setup(x => x.GetExceltraceOut(It.IsAny <string>()))
            .Returns(new MemoryStream());


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

            user.Setup(u => u.Claims).Returns(claims);
            TraceableBeacukaiController controller = new TraceableBeacukaiController(mockFacade.Object, GetServiceProvider().Object);

            controller.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";


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

            Assert.Equal("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", response.GetType().GetProperty("ContentType").GetValue(response, null));
        }
        public void Should_Error_Get_Xls_Trace_Out()
        {
            var mockFacade = new Mock <ITraceableBeacukaiFacade>();

            mockFacade.Setup(x => x.GetExceltraceOut(It.IsAny <string>()))
            .Returns(new MemoryStream());

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

            user.Setup(u => u.Claims).Returns(claims);
            TraceableBeacukaiController controller = new TraceableBeacukaiController(mockFacade.Object, GetServiceProvider().Object);

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


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

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

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


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

            user.Setup(u => u.Claims).Returns(claims);
            TraceableBeacukaiController controller = new TraceableBeacukaiController(mockFacade.Object, GetServiceProvider().Object);

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

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

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