Exemplo n.º 1
0
        public void TestPipeConnectorFetchesCallResponse()
        {
            CallResult callResultToFetch = new CallResult();

            Mock <IFormatter> formatterMock = new Mock <IFormatter>();

            formatterMock
            .Setup(x => x.Deserialize(It.IsAny <Stream>()))
            .Returns(callResultToFetch);
            Mock <IWrapperProcessStarter> wrapperProcessStarterMock = new Mock <IWrapperProcessStarter>();
            Mock <PipeStreamFactory>      pipeStreamFactoryMock     = GetPipeStreamFactoryMock();

            PipeToken      pipeToken     = new PipeToken(Guid.NewGuid().ToString());
            IPipeConnector pipeConnector = new PipeConnector(formatterMock.Object, wrapperProcessStarterMock.Object, pipeStreamFactoryMock.Object, pipeToken);

            CallResult actualCallResult = pipeConnector.ReceiveCallResponse();

            formatterMock.Verify(mock => mock.Deserialize(It.IsAny <PipeStream>()), Times.AtLeast(1));
            Assert.AreEqual(callResultToFetch, actualCallResult);
        }
Exemplo n.º 2
0
        public void TestThrowsExceptionIfContainedInCallResult()
        {
            CallResult callResultToFetch = new CallResult();

            callResultToFetch.Exception = new LegacyWrapperException();

            Mock <IFormatter> formatterMock = new Mock <IFormatter>();

            formatterMock
            .Setup(x => x.Deserialize(It.IsAny <Stream>()))
            .Returns(callResultToFetch);
            Mock <IWrapperProcessStarter> wrapperProcessStarterMock = new Mock <IWrapperProcessStarter>();
            Mock <PipeStreamFactory>      pipeStreamFactoryMock     = GetPipeStreamFactoryMock();

            PipeToken      pipeToken     = new PipeToken(Guid.NewGuid().ToString());
            IPipeConnector pipeConnector = new PipeConnector(formatterMock.Object, wrapperProcessStarterMock.Object, pipeStreamFactoryMock.Object, pipeToken);

            pipeConnector.ReceiveCallResponse();

            Assert.Fail("Exception should have been thrown by PipeConnector");
        }