public void Initialize() { var response = new ConnectionResponse { CommunicationToken = Guid.NewGuid(), ConnectionEstablished = true }; logger = new Mock <ILogger>(); proxyObjectFactory = new Mock <IProxyObjectFactory>(); proxy = new Mock <IProxyObject>(); proxy.Setup(p => p.Connect(It.IsAny <Guid>())).Returns(response); proxy.Setup(o => o.State).Returns(CommunicationState.Opened); proxyObjectFactory.Setup(f => f.CreateObject(It.IsAny <string>())).Returns(proxy.Object); sut = new ClientProxy("net.pipe://random/address/here", proxyObjectFactory.Object, logger.Object); sut.Connect(Guid.NewGuid()); }