public void Should_Error_Get_All_Data() { var mockFacade = new Mock <IGarmentReturnCorrectionNoteFacade>(); var mockMapper = new Mock <IMapper>(); GarmentReturnCorrectionNoteController controller = new GarmentReturnCorrectionNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object); var response = controller.Get(); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }
public void Should_Error_Get_Data_By_Id() { var mockFacade = new Mock <IGarmentReturnCorrectionNoteFacade>(); mockFacade.Setup(x => x.ReadById(It.IsAny <int>())) .Returns(Model); var mockMapper = new Mock <IMapper>(); GarmentReturnCorrectionNoteController controller = new GarmentReturnCorrectionNoteController(GetServiceProvider().Object, mockMapper.Object, mockFacade.Object); var response = controller.Get(It.IsAny <int>()); Assert.Equal((int)HttpStatusCode.InternalServerError, GetStatusCode(response)); }
private void Test_Get_PDF_By_Id(string correctionType) { var Model = this.Model; Model.CorrectionType = correctionType; var mockFacade = new Mock <IGarmentReturnCorrectionNoteFacade>(); mockFacade.Setup(x => x.ReadById(It.IsAny <int>())) .Returns(Model); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>())) .Returns(ViewModel); var garmentdeliveryOrder = new GarmentDeliveryOrder { DOCurrencyRate = 1, Items = new List <GarmentDeliveryOrderItem> { new GarmentDeliveryOrderItem { Details = Model.Items.Select(i => new GarmentDeliveryOrderDetail { Id = i.DODetailId }).ToList() } } }; var mockGarmentDeliveryOrderFacade = new Mock <IGarmentDeliveryOrderFacade>(); mockGarmentDeliveryOrderFacade.Setup(x => x.ReadById(It.IsAny <int>())) .Returns(garmentdeliveryOrder); var mockGarmentInternalPurchaseOrderFacade = new Mock <IGarmentInternalPurchaseOrderFacade>(); mockGarmentInternalPurchaseOrderFacade.Setup(x => x.ReadById(It.IsAny <int>())) .Returns(new GarmentInternalPurchaseOrder { UnitCode = "UnitCode" }); GarmentReturnCorrectionNoteController controller = GetController(mockFacade, null, mockMapper, mockGarmentDeliveryOrderFacade, mockGarmentInternalPurchaseOrderFacade); controller.ControllerContext.HttpContext.Request.Headers["Accept"] = "application/pdf"; var response = controller.Get(It.IsAny <int>()); Assert.NotNull(response.GetType().GetProperty("FileStream")); }
public void Should_Success_Get_Data_By_Id() { var mockFacade = new Mock <IGarmentReturnCorrectionNoteFacade>(); mockFacade.Setup(x => x.ReadById(It.IsAny <int>())) .Returns(Model); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <GarmentCorrectionNoteViewModel>(It.IsAny <GarmentCorrectionNote>())) .Returns(ViewModel); GarmentReturnCorrectionNoteController controller = GetController(mockFacade, null, mockMapper); var response = controller.Get(It.IsAny <int>()); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }
public void Should_Success_Get_All_Data() { var mockFacade = new Mock <IGarmentReturnCorrectionNoteFacade>(); mockFacade.Setup(x => x.Read(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>(), null, It.IsAny <string>())) .Returns(Tuple.Create(new List <GarmentCorrectionNote>(), 0, new Dictionary <string, string>())); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <List <GarmentCorrectionNoteViewModel> >(It.IsAny <List <GarmentCorrectionNote> >())) .Returns(new List <GarmentCorrectionNoteViewModel> { ViewModel }); GarmentReturnCorrectionNoteController controller = GetController(mockFacade, null, mockMapper); var response = controller.Get(); Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response)); }