Rhinomock error Expected #1, Actual #0. Source=<Cannot evaluate the exception source>

474 views
Skip to first unread message

Jaison Peter

unread,
Mar 14, 2018, 1:54:57 AM3/14/18
to Rhino.Mocks
I am a newbie to Rhino

I have method written like below :

    [TestMethod]
        public void WhenProducitonOrderList_IsNotFromPaperlessWarehouse_POList_IsNotSent()
        {
            // arrange
            MockProductionOrders.ProductCodeInfoList = new string[]
            {
                "5150-000002,INPA160336611,5150-000020,C,30,FR,,,,,,,,INPA,5150",
                "5150-000001,INGA1390368811,5150-000001,C,30,FR,,,,,,,,INGA,5150"
            };

            var purchPRDListMock = MockProductionOrders.CreateTestProductionOrders();
            var purchPRDListRepositoryMock = MockRepository.GenerateMock<IProductionOrderRepository>();
            purchPRDListRepositoryMock.Expect(x => x.GetNewProductionOrders(Arg<DateTime>.Is.Anything)).Return(purchPRDListMock);
            var purchPRDListEnueratedMock = MockProductionOrders.CreateTestProductionOrder();
            var productionOrderManagerMock = MockRepository.GenerateMock<IProductionOrderManager>();
            productionOrderManagerMock.Expect(x => x.SendToWms(Arg<IEnumerable<ProductionOrderToWMS>>.Is.Anything)).Return(purchPRDListEnueratedMock);
            var purchPRDValidator = new ProductionOrderValidator();
            var purchaseOrderToWmsServiceMock = MockRepository.GenerateMock<PurchaseOrderToWMSPort>();
            var soapAdapterMock = MockRepository.GenerateMock<ISoapAdapter<PurchaseOrderToWMSPort>>();
            soapAdapterMock.Expect(x => x.GetService()).Return(purchaseOrderToWmsServiceMock);
            var purchPRDRequestMock = MockRepository.GenerateMock<PurchaseOrderToWMSOperationRequest>();
            var axToWmsPRDManager = new AxToWmsProdManager(purchPRDListRepositoryMock, purchPRDValidator, productionOrderManagerMock, MockRepository.GenerateMock<IAuditor>());          
            
            // act
            axToWmsPRDManager.Execute();

            //assert           
            //purchPRDListRepositoryMock.VerifyAllExpectations();
            //productionOrderManagerMock.VerifyAllExpectations();
            //purchaseOrderToWmsServiceMock.VerifyAllExpectations();            

            purchaseOrderToWmsServiceMock.AssertWasCalled(x => x.PurchaseOrderToWMSOperation(purchPRDRequestMock));

        }


the line below throws error :

>  purchaseOrderToWmsServiceMock.AssertWasCalled(x =>
> x.PurchaseOrderToWMSOperation(purchPRDRequestMock));

This is error:


> Rhino.Mocks.Exceptions.ExpectationViolationException occurred  
> HResult=0x80131500  
> Message=PurchaseOrderToWMSPort.PurchaseOrderToWMSOperation(Castle.Proxies.PurchaseOrderToWMSOperationRequestProxy2641b9f9d16044aeb43d9f73bb77d369);
> Expected #1, Actual #0.   Source=<Cannot evaluate the exception
> source>   StackTrace:    at
> Rhino.Mocks.RhinoMocksExtensions.AssertWasCalled[T](T mock, Action`1
> action, Action`1 setupConstraints)    at
> Rhino.Mocks.RhinoMocksExtensions.AssertWasCalled[T](T mock, Func`2
> action)    at
> ETG.AXHub.BLL.PWSTests.PurchPRD.AxToWmsPurchPRDManagerTests.WhenProducitonOrderList_IsNotFromPaperlessWarehouse_POList_IsNotSent()
> in
> C:\AXRepo\ETG.IHub\PWS\ETG.AXHub.BLL.PWSTests\PurchPRD\AxToWmsPurchPRDManagerTests.cs:line
> 84


Could you help me what is going wrong?


**Updates**

> I changed the line as below, still i am getting same error

`purchaseOrderToWmsServiceMock.AssertWasCalled(x => x.PurchaseOrderToWMSOperation(Arg<PurchaseOrderToWMSOperationRequest>.Is.Anything));` –



> when i changed the line to below it is NOT throwing any errors

 `purchaseOrderToWmsServiceMock.AssertWasNotCalled(x => x.PurchaseOrderToWMSOperation(Arg<PurchaseOrderToWMSOperationRequest>.Is.Anything));`
Reply all
Reply to author
Forward
0 new messages