public void Should_Success_Get_All_Data_ByName()
        {
            var mockFacade = new Mock <IGarmentInternalPurchaseOrderFacade>();

            mockFacade.Setup(x => x.ReadName(null, "{}"))
            .Returns(new List <GarmentInternalPurchaseOrder>());

            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(x => x.Map <List <GarmentInternalPurchaseOrderViewModel> >(It.IsAny <List <GarmentInternalPurchaseOrder> >()))
            .Returns(new List <GarmentInternalPurchaseOrderViewModel>());

            GarmentInternalPurchaseOrderController controller = GetController(mockFacade, null, mockMapper);
            var response = controller.ByName(null, null);

            Assert.Equal((int)HttpStatusCode.OK, GetStatusCode(response));
        }
Ejemplo n.º 2
0
        public void Should_Fail_GetByName()
        {
            //Setup
            var facadeMock = new Mock <IGarmentInternalPurchaseOrderFacade>();

            facadeMock
            .Setup(x => x.ReadName(It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new Exception());

            var mapperMock = new Mock <IMapper>();

            mapperMock
            .Setup(x => x.Map <List <GarmentInternalPurchaseOrderViewModel> >(It.IsAny <List <GarmentInternalPurchaseOrder> >()))
            .Returns(new List <GarmentInternalPurchaseOrderViewModel>());

            //Act
            GarmentInternalPurchaseOrderController controller = GetController(facadeMock, null, mapperMock);
            var response = controller.ByName(null, null);

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