public void OAPHShouldSkipFirstValueIfItMatchesTheInitialValue()
        {
            var input = new[] { 1, 2, 3 }.ToObservable();
            var output = new List<int>();

            (new TestScheduler()).With(sched => {
                var fixture = new ObservableAsPropertyHelper<int>(input,
                    x => output.Add(x), 1);

                sched.Start();

                Assert.Equal(input.LastAsync().Wait(), fixture.Value);

                (new[] { 1, 2, 3 }).AssertAreEqual(output);
            });
        }
        public void OAPHShouldFireChangeNotifications()
        {
            var input = new[] {1, 2, 3, 3, 4}.ToObservable();
            var output = new List<int>();

            (new TestScheduler()).With(sched => {
                var fixture = new ObservableAsPropertyHelper<int>(input,
                    x => output.Add(x), -5);

                sched.Start();

                // Note: Why doesn't the list match the above one? We're supposed
                // to suppress duplicate notifications, of course :)
                (new[] { -5, 1, 2, 3, 4 }).AssertAreEqual(output);
            });
        }
Exemplo n.º 3
0
		public void Delta_ShouldReturnCorrectValue(
		  TestScheduler scheduler)
		{
			//arrange
			var source = scheduler.CreateColdObservable(
				OnNext(0, 0),
				OnNext(1, 10),
				OnNext(2, 8),
				OnNext(3, 16),
				OnNext(4, 20),
				OnNext(5, 10));

			//act
			var actual = scheduler.Start(() => source.Delta((previous, current) => previous - current));

			//assert
			var expected = new[] {-10, 2, -8, -4, 10};
			actual.Values().ShouldAllBeEquivalentTo(expected);
		}
Exemplo n.º 4
0
        public void MessageBusSmokeTest()
        {
            var input = new[] {1, 2, 3, 4};

            var result = (new TestScheduler()).With(sched => {
                var source = new Subject<int>();
                var fixture = new MessageBus();

                fixture.RegisterMessageSource(source, "Test");
                Assert.False(fixture.IsRegistered(typeof (int)));
                Assert.False(fixture.IsRegistered(typeof (int), "Foo"));

                var output = fixture.Listen<int>("Test").CreateCollection();

                input.Run(source.OnNext);

                sched.Start();
                return output;
            });

            input.AssertAreEqual(result);
        }