public async Task Should_Return_Last_Element()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

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

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

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

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

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

                // When
                await sut.PushModal(new PageViewModelMock(), "modal");

                // Then
                sut.View.Received().PushModal(Arg.Any <IPageViewModel>(), "modal");
            }
            public async Task Should_Throw_If_View_Model_Null()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();

                // When
                var result = await Record.ExceptionAsync(async() => await sut.PushModal(null)).ConfigureAwait(false);

                // Then
                result.ShouldBeOfType <ArgumentNullException>();
            }
            public async Task Should_Not_Pop()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture().WithView(Substitute.For <IView>());
                await sut.PushModal(new PageViewModelMock());

                // When
                await sut.TopModal();

                // Then
                await sut.View.DidNotReceive().PopModal();
            }
            public async Task Should_Return_Unit()
            {
                // Given, When
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock());

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

                // Then
                result.ShouldBeOfType <Unit>();
            }
            public async Task Should_Receive_Pop_Page()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock());

                // When
                await sut.PopPage();

                // Then
                sut.View.Received().PopPage();
            }
            public async Task Should_Push_Modal()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock());

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

                // Then
                result.ShouldNotBeNull();
                result.ShouldBeOfType <PageViewModelMock>();
            }
            public void Should_Receive_Pop_Page()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

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

                // Then
                fixture.View.Received().PopPage();
            }
            public async Task Should_Receive_Pop_Modal()
            {
                // Given, When
                var fixture = new ViewStackServiceFixture();

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

                // When
                fixture.PopModal().Subscribe();

                // Then
                await fixture.View.Received().PopModal();
            }
            public async Task Should_Return_Unit()
            {
                // Given, When
                var fixture = new ViewStackServiceFixture();

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

                // When
                var result = await fixture.PopModal();

                // Then
                result.Should().BeOfType <Unit>();
            }
            public async Task Should_Pop_Page()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

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

                // Then
                result.Should().BeEmpty();
            }
            public void Should_Pop_Modal()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

                // When
                fixture.ViewStackService.ModalStack.FirstAsync().Wait().Count.Should().Be(1);
                fixture.PopModal().Subscribe();

                // Then
                fixture.ViewStackService.ModalStack.FirstAsync().Wait().Should().BeEmpty();
            }
            public async Task Should_Pop_Page()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock());

                // When
                await sut.PopPage();

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

                // Then
                result.ShouldBeEmpty();
            }
            public async Task Should_Push_Modal()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

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

                // Then
                result.Should().NotBeNull();
                result.Should().BeOfType <PageViewModelMock>();
            }
            public async Task Should_Push_Page_On_Stack()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();

                // When
                await sut.PushModal(new PageViewModelMock(), "modal");

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

                // Then
                result.ShouldNotBeEmpty();
                result.Count.ShouldBe(1);
            }
            public async Task Should_Push_And_Pop(int amount)
            {
                // Given
                var fixture = new ViewStackServiceFixture();

                fixture.PushModal(new PageViewModelMock(), "modal", amount).Subscribe();
                fixture.ViewStackService.ModalStack.FirstAsync().Wait().Count.Should().Be(amount);
                fixture.PopModal(amount).Subscribe();

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

                // Then
                result.Should().BeEmpty();
            }
            public async Task Should_Push_And_Pop(int amount)
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock(), "modal", amount);

                sut.ModalStack.FirstAsync().Wait().Count.ShouldBe(amount);
                await sut.PopModal(amount);

                // When
                var result = await sut.ModalStack.FirstAsync();

                // Then
                result.ShouldBeEmpty();
            }
            public async Task Should_Pop_Modal()
            {
                // Given
                ViewStackService sut = new ViewStackServiceFixture();
                await sut.PushModal(new PageViewModelMock());

                // When
                var item = await sut.ModalStack.FirstAsync();

                item.Count.ShouldBe(1);
                await sut.PopModal();

                // Then
                item = await sut.ModalStack.FirstAsync();

                item.ShouldBeEmpty();
            }
            public async Task Should_Pop_Modal()
            {
                // Given
                var fixture = new ViewStackServiceFixture();

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

                // When
                var item = await fixture.ViewStackService.ModalStack.FirstAsync();

                item.Count.ShouldBe(1);
                fixture.PopModal().Subscribe();

                // Then
                item = await fixture.ViewStackService.ModalStack.FirstAsync();

                item.ShouldBeEmpty();
            }