예제 #1
0
        public void GettingSelectedItem_AfterSelectedItemIsRemovedFromTheList_ReturnsTheItemSuppliedByTheSelectionPolicy
            ()
        {
            ITestItem firstItem  = new Mock <ITestItem>().Object;
            ITestItem secondItem = new Mock <ITestItem>().Object;

            _stubModels.Add(firstItem);
            _stubModels.Add(secondItem);

            TestSingleItemSelector test = BuildTestSubject();

            _fakeSelectionPolicy.
            Setup(x => x.ModifySelectedItem(test, firstItem)).
            Returns(firstItem);
            _fakeSelectionPolicy.
            Setup(x => x.ModifySelectedItem(test, null)).
            Returns(firstItem);

            test.Initialize();

            _fakeSelectionPolicy.
            Setup(x => x.ModifySelectedItem(test, null)).
            Returns(secondItem);

            _stubModels.Remove(firstItem);

            Assert.Same(secondItem, test.SelectedItem);
        }
예제 #2
0
        public void GettingSelectedItem_WhenThereAreNoItems_IsNull()
        {
            TestSingleItemSelector test = BuildTestSubject();

            test.Initialize();

            Assert.Null(test.SelectedItem);
        }
예제 #3
0
        public void GettingSelectedItem_WhenAnItemIsAddedToAnEmptyList_ChangesToTheItemGivenByPolicy()
        {
            TestSingleItemSelector test = BuildTestSubject();

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

            test.Initialize();

            _fakeSelectionPolicy.
            Setup(x => x.ModifySelectedItem(test, (ITestItem)null)).
            Returns(item);

            test.AssertThatChangeNotificationIsRaisedBy(x => x.SelectedItem)
            .When(() => _stubModels.Add(item));

            Assert.Same(item, test.SelectedItem);
        }
예제 #4
0
        public void GettingSelectedItem_Initially_ReturnsItemFromSelectionPolicy()
        {
            ITestItem firstItem = new Mock <ITestItem>().Object;

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

            _fakeSelectionPolicy.
            Setup(x => x.ModifySelectedItem(It.IsAny <TestSingleItemSelector>(), null)).
            Returns(firstItem).
            Verifiable();

            TestSingleItemSelector test = BuildTestSubject();

            test.Initialize();

            Assert.Same(firstItem, test.SelectedItem);
            _fakeSelectionPolicy.VerifyAll();
        }