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); }
public void GettingSelectedItem_WhenThereAreNoItems_IsNull() { TestSingleItemSelector test = BuildTestSubject(); test.Initialize(); Assert.Null(test.SelectedItem); }
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); }
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(); }