Beispiel #1
0
 public HostService(
     ISpy spy,
     Foo foo)
 {
     _spy = spy;
     _foo = foo;
 }
            public void InterceptViaAttributes()
            {
                Recorder.Records.Clear();
                DependencyContainer container = new DependencyContainer();

                container.RegisterTypeMapping <ISpy, SpyInterfaceAttributes>();

                ISpy obj = container.Get <ISpy>();

                obj.InterceptedMethod();

                Assert.Equal(3, Recorder.Records.Count);
                Assert.Equal("Before Method", Recorder.Records[0]);
                Assert.Equal("In Method", Recorder.Records[1]);
                Assert.Equal("After Method", Recorder.Records[2]);
            }
            public void InterceptViaCode()
            {
                Recorder.Records.Clear();
                DependencyContainer container = new DependencyContainer();

                container.RegisterTypeMapping <ISpy, SpyInterface>();
                container.InterceptInterface <SpyInterface>(typeof(ISpy).GetMethod("InterceptedMethod"),
                                                            new RecordingHandler());

                ISpy obj = container.Get <ISpy>();

                obj.InterceptedMethod();

                Assert.Equal(3, Recorder.Records.Count);
                Assert.Equal("Before Method", Recorder.Records[0]);
                Assert.Equal("In Method", Recorder.Records[1]);
                Assert.Equal("After Method", Recorder.Records[2]);
            }
            public void ExceptionsAreUnchanged()
            {
                Recorder.Records.Clear();
                DependencyContainer container = new DependencyContainer();

                container.RegisterTypeMapping <ISpy, SpyInterface>();
                container.InterceptInterface <SpyInterface>(typeof(ISpy).GetMethod("ThrowsException"),
                                                            new RecordingHandler());

                ISpy obj = container.Get <ISpy>();

                Assert.Throws <Exception>(delegate
                {
                    obj.ThrowsException();
                });

                Assert.Equal(3, Recorder.Records.Count);
                Assert.Equal("Before Method", Recorder.Records[0]);
                Assert.Equal("In Method", Recorder.Records[1]);
                Assert.Equal("After Method", Recorder.Records[2]);
            }
Beispiel #5
0
 public WaitList(ISpy spy)
 {
     this.spy = spy;
 }
Beispiel #6
0
 public Reservation(ISpy spy)
 {
     this.spy = spy;
     this.Id  = Guid.NewGuid();
     this.spy.Spy("Reservation ctor");
 }
Beispiel #7
0
 public RetryHandler(ISpy spy)
 {
     this.spy = spy;
 }
Beispiel #8
0
 public MultipleCommandCommandHandler(ISpy spy)
 {
     this.spy = spy;
 }
Beispiel #9
0
 public Order(ISpy spy)
 {
     this.spy = spy;
     this.Id  = Guid.NewGuid();
     this.spy.Spy("Order ctor");
 }
 static bool IsTrue(ISpy spy)
 {
     spy.Is();
     return(true);
 }
Beispiel #11
0
 public Foo(ISpy spy)
 {
     _spy = spy;
 }
 public FakeEventSubscriberWithException(ISpy spy)
 {
     this.spy = spy;
 }
Beispiel #13
0
 public static string Stringify(this ISpy soldier) => $"{Stringify((ISoldier) soldier)}\r\nCode Number: {soldier.CodeNumber}";
Beispiel #14
0
 public Payment(ISpy spy)
 {
     this.spy = spy;
     this.Id  = Guid.NewGuid();
     this.spy.Spy("Payment ctor");
 }
Beispiel #15
0
 public AggregateSubscriber(ISpy spy)
 {
     this.spy = spy;
 }