Beispiel #1
0
        public void errors_saving_data_are_surfaced()
        {
            var api = new ApiMockBuilder()
                      .WithSaveDinosaur(new InvalidOperationException("foo"))
                      .Build();
            var sut = new DinosaurDetailsViewModelBuilder()
                      .WithTestScheduler(out var scheduler)
                      .WithApi(api)
                      .Build();

            sut.Name = "Barney";
            scheduler.AdvanceByMs(2001);

            Assert.NotNull(sut.Error);
            Assert.Equal("foo", sut.Error.Exception.Message);

            api
            .When(x => x.SaveDinosaur(It.IsAny <Dinosaur>()))
            .Return(Observable.Return(Unit.Default));
            sut
            .Error
            .RetryCommand
            .Execute(null);
            scheduler.AdvanceByMs(1);
            Assert.Null(sut.Error);
        }
Beispiel #2
0
        public void errors_deleting_data_are_surfaced()
        {
            var api = new ApiMockBuilder()
                      .WithDeleteDinosaur(new InvalidOperationException("foo"))
                      .Build();
            var sut = new DinosaurDetailsViewModelBuilder()
                      .WithApi(api)
                      .WithConfirmDeleteInteraction(true)
                      .Build();

            sut
            .DeleteCommand
            .Execute()
            .Subscribe(
                _ => { },
                _ => { });

            Assert.NotNull(sut.Error);
            Assert.Equal("foo", sut.Error.Exception.Message);

            api
            .When(x => x.DeleteDinosaur(It.IsAny <int>()))
            .Return(Observable.Return(Unit.Default));
            sut
            .Error
            .RetryCommand
            .Execute(null);
            Assert.Null(sut.Error);
        }
Beispiel #3
0
        public void errors_retrieving_data_are_surfaced()
        {
            var api = new ApiMockBuilder()
                      .WithGetDinosaur(new InvalidOperationException("foo"))
                      .Build();
            var sut = new DinosaurDetailsViewModelBuilder()
                      .WithApi(api)
                      .Build();

            Assert.NotNull(sut.Error);
            Assert.Equal("foo", sut.Error.Exception.Message);

            api
            .When(x => x.GetDinosaur(It.IsAny <int>()))
            .Return(Observable.Return(default(Dinosaur)));
            sut
            .Error
            .RetryCommand
            .Execute(null);
            Assert.Null(sut.Error);
        }