public void Should_Success_Get_Report_Data() { var mockFacade = new Mock<IUnitPaymentPriceCorrectionNoteFacade>(); mockFacade.Setup(x => x.GetReport(null,null, It.IsAny<int>(), It.IsAny<int>(), "{}",It.IsAny<int>())) .Returns(Tuple.Create( new List<UnitPaymentPriceCorrectionNoteReportViewModel> { ViewModel },25)); var mockMapper = new Mock<IMapper>(); mockMapper.Setup(x => x.Map<List<UnitPaymentPriceCorrectionNoteReportViewModel>>(It.IsAny<List<UnitPaymentCorrectionNote>>())) .Returns(new List<UnitPaymentPriceCorrectionNoteReportViewModel> { ViewModel }); var user = new Mock<ClaimsPrincipal>(); var claims = new Claim[] { new Claim("username", "unittestusername") }; user.Setup(u => u.Claims).Returns(claims); UnitPaymentPriceCorrectionNoteReportController controller = new UnitPaymentPriceCorrectionNoteReportController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object); controller.ControllerContext = new ControllerContext() { HttpContext = new DefaultHttpContext() { User = user.Object } }; controller.ControllerContext.HttpContext.Request.Headers["x-timezone-offset"] = "0"; var response = controller.GetReport(null,null,1, 25, "{}"); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }
public void GetReport_Return_OK() { //Setup var facadeMock = new Mock <IUnitPaymentPriceCorrectionNoteFacade>(); facadeMock .Setup(x => x.GetReport(It.IsAny <DateTime?>(), It.IsAny <DateTime?>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(Tuple.Create(new List <UnitPaymentPriceCorrectionNoteReportViewModel> { ViewModel }, 25)); var mapperMock = new Mock <IMapper>(); mapperMock .Setup(x => x.Map <List <UnitPaymentPriceCorrectionNoteReportViewModel> >(It.IsAny <List <UnitPaymentCorrectionNote> >())) .Returns(new List <UnitPaymentPriceCorrectionNoteReportViewModel> { ViewModel }); //Act UnitPaymentPriceCorrectionNoteReportController controller = GetController(GetServiceProvider(), mapperMock, facadeMock); var response = controller.GetReport(null, null, 1, 25, "{}"); //Assert Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }