public void GettingPresenters_WhenAModelIsAdded_ContainsOnePresenter()
        {
            ListPresenter <ITestItem, ITestItemPresenter> test = new TestListPresenter(_stubModels, BuildItemPresenter);

            test.Initialize();

            _stubModels.Add(new Mock <ITestItem>().Object);

            Assert.Equal(1, test.Screens.Count);
        }
        public void Initialize_WhenThereIsAItem_OpensItemPresenter()
        {
            _stubModels.Add(new Mock <ITestItem>().Object);

            ListPresenter <ITestItem, ITestItemPresenter> test = new TestListPresenter(_stubModels,
                                                                                       x => _stubItemPresenter.Object);

            test.Initialize();

            Assert.Contains(_stubItemPresenter.Object, test.Screens);
        }
        public void GettingScreens_WhenTheModelsListIsCleared_IsEmpty()
        {
            var models = new ObservableCollection <ITestItem> {
                new Mock <ITestItem>().Object
            };

            ListPresenter <ITestItem, ITestItemPresenter> test = new TestListPresenter(models, BuildItemPresenter);

            test.Initialize();

            models.Clear();

            Assert.Equal(0, test.Screens.Count);
        }
        public void Shutdown__ShutsDownItemPresenters()
        {
            ListPresenter <ITestItem, ITestItemPresenter> test = new TestListPresenter(_stubModels,
                                                                                       x => _stubItemPresenter.Object);

            test.Initialize();

            ITestItem testItem = new Mock <ITestItem>().Object;

            _stubItemPresenter.Setup(x => x.Model).Returns(testItem);
            _stubModels.Add(testItem);
            test.Shutdown();

            _stubItemPresenter.Verify(x => x.Shutdown());
        }
        public void GettingScreens_WhenTheLastModelIsRemoved_IsEmpty()
        {
            var stubItem = new Mock <ITestItem>();

            _stubItemPresenter.Setup(x => x.Model).Returns(stubItem.Object);
            _stubModels.Add(stubItem.Object);

            ListPresenter <ITestItem, ITestItemPresenter> test = new TestListPresenter(_stubModels, BuildItemPresenter);

            test.Initialize();

            _stubModels.RemoveAt(0);

            Assert.Empty(test.Screens);
        }