private IServant TestGenerate <T>(T subject) { Type type = null; new Action(() => type = _creator.GenerateServant <T>()) .Should().NotThrow(); type.Should().NotBeNull(); _objectId = (ulong)_random.Next(); IServant servant = _creator.CreateServant(_endPoint.Object, _channel.Object, _objectId, subject); servant.Should().NotBeNull(); servant.ObjectId.Should().Be(_objectId); servant.Subject.Should().BeSameAs(subject); return(servant); }
public void TestCreateServant2() { using (var endPoint = CreateClient()) { var subject = new Mock <IEventInt32>(); IServant servant = null; const string reason = "because a servant can always be created - its usage may however not work depending on the endpoint's connection status"; new Action(() => servant = endPoint.CreateServant(0, subject.Object)) .Should().NotThrow(reason); servant.Should().NotBeNull(reason); new Action(() => subject.Raise(x => x.Foobar += null, 42)) .Should().Throw <NotConnectedException>( "because the endpoint is not connected to any other endpoint and thus there cannot be a proxy on which the event can ever be executed"); } }