Beispiel #1
0
        public void EndTransmission()
        {
            var mockery = new MockRepository();
            var subscriber = mockery.StrictMock<IObserver<string>>();

            var watched = new Watched();

            using (mockery.Record()) {
                subscriber.OnCompleted();
            }

            using (mockery.Playback())
            using (var unsubscriber = watched.Subscribe(subscriber)) {
                watched.EndTransmission();
            }
        }
Beispiel #2
0
        public void Send()
        {
            var mockery = new MockRepository();
            var subscriber = mockery.StrictMock<IObserver<string>>();

            var message = "test message";

            var watched = new Watched();

            using (mockery.Record()) {
                subscriber.OnNext(message);
            }

            using (mockery.Playback())
            using (var unsubscriber = watched.Subscribe(subscriber)) {
                watched.Send(message);
            }
        }
Beispiel #3
0
        public void Send_Errors_When_String_Is_Null()
        {
            var mockery = new MockRepository();
            var subscriber = mockery.StrictMock<IObserver<string>>();

            string message = null;

            var watched = new Watched();

            using (mockery.Record()) {
                subscriber.OnError(new Exception());
                LastCall.Constraints(Is.TypeOf(typeof(ArgumentNullException))
                    && Property.Value("Message", "Unable to process null strings" + Environment.NewLine +"Parameter name: message"));
            }

            using (mockery.Playback())
            using (var unsubscriber = watched.Subscribe(subscriber)) {
                watched.Send(message);
            }
        }