Esempio n. 1
0
            public async Task Should_Return_Last_Element()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

                fixture.PushPage(new PageViewModelMock("1")).Subscribe();
                fixture.PushPage(new PageViewModelMock("2")).Subscribe();

                // When
                var result = await fixture.ViewStackService.TopPage();

                // Then
                result.Should().BeOfType <PageViewModelMock>();
                result.Id.Should().Be("2");
            }
Esempio n. 2
0
            public async Task Should_Return_Last_Element()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushPage(new PageViewModelMock("1"));

                await sut.PushPage(new PageViewModelMock("2"));

                // When
                var result = await sut.TopPage();

                // Then
                result.ShouldBeOfType <PageViewModelMock>();
                result.Id.ShouldBe("2");
            }
Esempio n. 3
0
            public async Task Should_Clear_Navigation_Stack_If_Reset()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture().WithView(Substitute.For <IView>());

                // When
                await sut.PushPage(new PageViewModelMock(), pages : 3);

                await sut.PushPage(new PageViewModelMock(), resetStack : true);

                var result = await sut.PageStack.FirstOrDefaultAsync();

                // Then
                result.ShouldHaveSingleItem();
            }
Esempio n. 4
0
            public void Should_Receive_Push_Page()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

                // When
                fixture.PushPage(new PageViewModelMock());

                // Then
                fixture.View.Received().PushPage(Arg.Any <IPageViewModel>(), null, false, true);
            }
Esempio n. 5
0
            public async Task Should_Receive_Push_Page()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture().WithView(Substitute.For <IView>());

                // When
                await sut.PushPage(new PageViewModelMock());

                // Then
                sut.View.Received().PushPage(Arg.Any <IPageViewModel>(), null, false, true);
            }
Esempio n. 6
0
            public async Task Should_Not_Pop()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture().WithView(Substitute.For <IView>());
                await sut.PushPage(new PageViewModelMock());

                // When
                await sut.TopPage();

                // Then
                await sut.View.DidNotReceive().PopPage();
            }
Esempio n. 7
0
            public async Task Should_Return_Unit()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushPage(new PageViewModelMock());

                // When
                var result = await sut.PopPage();

                // Then
                result.ShouldBeOfType <Unit>();
            }
Esempio n. 8
0
            public async Task Should_Not_Pop()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

                fixture.PushPage(new PageViewModelMock()).Subscribe();

                // When
                fixture.ViewStackService.TopPage().Subscribe();

                // Then
                await fixture.View.DidNotReceive().PopPage();
            }
Esempio n. 9
0
            public async Task Should_Return_Unit()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

                fixture.PushPage(new PageViewModelMock()).Subscribe();

                // When
                var result = await fixture.ViewStackService.PopPage();

                // Then
                result.Should().BeOfType <Unit>();
            }
Esempio n. 10
0
            public async Task Should_Push_Page_On_Stack()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();

                // When
                await sut.PushPage(new PageViewModelMock());

                var result = await sut.PageStack.FirstAsync();

                // Then
                result.ShouldNotBeEmpty();
                result.Count.ShouldBe(1);
            }
Esempio n. 11
0
            public async Task Should_Push_Page()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();

                // When
                await sut.PushPage(new PageViewModelMock());

                var result = await sut.TopPage();

                // Then
                result.ShouldNotBeNull();
                result.ShouldBeOfType <PageViewModelMock>();
            }
Esempio n. 12
0
            public async Task Should_Have_One_Item_On_Stack()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushPage(new PageViewModelMock(), pages : 3);

                await sut.PopToRootPage();

                // When
                var result = await sut.PageStack.FirstOrDefaultAsync();

                // Then
                result.ShouldHaveSingleItem();
            }
Esempio n. 13
0
            public async Task Should_Return_Single_Notification()
            {
                // Given
                int count            = 0;
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushPage(new PageViewModelMock(), pages : 3);

                sut.View.PagePopped.Subscribe(_ =>
                {
                    count++;
                });

                // When
                await sut.PopToRootPage();

                // Then
                count.ShouldBe(1);
            }
Esempio n. 14
0
            public async Task Should_Throw_If_View_Model_Null()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();

                // When
                var result = await Should.ThrowAsync <ArgumentNullException>(async() => await sut.PushPage(null)).ConfigureAwait(false);

                // Then
                result.ParamName.ShouldBe("page");
            }