Beispiel #1
0
        public void RefreshAsync_WithTimeout_ShouldThrow(
            [Frozen] ThrowingTestScheduler scheduler,
            ObservableViewModel <object> sut)
        {
            //arrange
            var observer = scheduler.CreateObserver <ObservableViewModelNotification>();

            sut.Subscribe(observer);
            scheduler.Schedule(TimeSpan.FromTicks(201), () => sut.Refresh());

            //act
            scheduler.Start();
            //await sut.RefreshAsync();

            //assert
            var actual   = observer.Values().ToArray();
            var expected = new[]
            {
                new ObservableViewModelNotification()
                {
                    Status = ObservableViewModelStatus.Initialized, Value = null
                },
                new ObservableViewModelNotification()
                {
                    Status = ObservableViewModelStatus.Updating, Value = null
                },
                new ObservableViewModelNotification()
                {
                    Status = ObservableViewModelStatus.Timeout, Value = null
                }
            };

            actual.ShouldAllBeEquivalentTo(expected);
        }
Beispiel #2
0
        public void ObserveCommandEvents_WithoutCommandAndWhenNotifyingOtherType_ShouldReturnCorrectValue(
            [Frozen] ThrowingTestScheduler scheduler,
            CommandEvents sut,
            TestCommandWithMultipleEvents command,
            string value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var result = scheduler.Start(() => sut.ObserveCommandEvents <TestCommandWithMultipleEvents, int>());

            //assert
            result.AssertExceptions();
            result.Values().Should().BeEmpty();
        }
Beispiel #3
0
        public void ObserveCommandEvents_ShouldReturnCorrectValue(
            [Frozen] ThrowingTestScheduler scheduler,
            CommandEvents sut,
            TestCommand command,
            string value)
        {
            //arrange
            scheduler.Schedule(TimeSpan.FromTicks(202), () => sut.NotifyEvent(command, value));

            //act
            var result = scheduler.Start(() => sut.ObserveCommandEvents <TestCommand, string>());

            //assert
            result.AssertExceptions();
            result.Values().First().Should().Be(value);
        }
		public void RefreshOn_SetRefreshOn(
			ThrowingTestScheduler scheduler,
			object refreshValue,
			ObservableViewModelBuilderOptions<object> sut)
		{
			//arrange
			var refreshOn = new Subject<object>();

			scheduler.Schedule(TimeSpan.FromTicks(201), () => refreshOn.OnNext(refreshValue));

			//act
			var actual = sut.RefreshOn(refreshOn)
							.ToViewModel();
			var result = scheduler.Start(() => actual.As<ObservableViewModel<object>>().RefreshOn);

			//assert
			result.Values().Should().HaveCount(1);
		}
Beispiel #5
0
        public void RefreshOn_SetRefreshOn(
            ThrowingTestScheduler scheduler,
            object refreshValue,
            ObservableViewModelBuilderOptions <object> sut)
        {
            //arrange
            var refreshOn = new Subject <object>();

            scheduler.Schedule(TimeSpan.FromTicks(201), () => refreshOn.OnNext(refreshValue));

            //act
            var actual = sut.RefreshOn(refreshOn)
                         .ToViewModel();
            var result = scheduler.Start(() => actual.As <ObservableViewModel <object> >().RefreshOn);

            //assert
            result.Values().Should().HaveCount(1);
        }
Beispiel #6
0
        public void RefreshOn_ShouldRefresh(
            [Frozen] ThrowingTestScheduler scheduler,
            [Frozen] Subject <Unit> refreshOn,
            [Frozen] object value,
            ObservableViewModel <object> sut)
        {
            //arrange
            var observer = scheduler.CreateObserver <ObservableViewModelNotification>();

            sut.Subscribe(observer);

            //act
            scheduler.Schedule(TimeSpan.FromTicks(201), () => refreshOn.OnNext(Unit.Default));
            scheduler.Start();

            //assert
            var expected = new ObservableViewModelNotification()
            {
                Status = ObservableViewModelStatus.Value,
                Value  = value
            };

            observer.Values().Last().ShouldBeEquivalentTo(expected);
        }