public void Test_UpdateChildSelectorCollection_WhenSpecificChildWasSelectedBeforeHand_ShouldRetainSelectedChild() { //---------------Set up test pack------------------- CreateFakeContactPersonWithNoFakeAddress(); var contactPerson = CreateFakeContactPersonWithManyAddresses(); var parentSelector = CreateControl(); var childSelector = CreateControl(); const string relationshipName = "Addresses"; parentSelector.BusinessObjectCollection = GetFakeContactPeople(); var originallySelectedAddress = contactPerson.Addresses[1]; BOColSelectorLinker <FakeContactPerson, FakeAddress> selectorLinker = new BOColSelectorLinker <FakeContactPerson, FakeAddress>(parentSelector, childSelector, relationshipName); parentSelector.SelectedBusinessObject = contactPerson; selectorLinker.UpdateChildSelectorCollection(); childSelector.SelectedBusinessObject = originallySelectedAddress; //---------------Assert Precondition---------------- Assert.AreSame(originallySelectedAddress, childSelector.SelectedBusinessObject); //---------------Execute Test ---------------------- selectorLinker.UpdateChildSelectorCollection(); //---------------Test Result ----------------------- Assert.AreSame(originallySelectedAddress, childSelector.SelectedBusinessObject); }
public void Test_UpdateChildSelectorCollection_WhenSomethingIsSelectedBeforeHand_ShouldUpdateChildSelector() { //---------------Set up test pack------------------- CreateFakeContactPersonWithNoFakeAddress(); var address = CreateFakeAddressWithFakeContactPerson(); var parentSelector = CreateControl(); var childSelector = CreateControl(); const string relationshipName = "Addresses"; parentSelector.BusinessObjectCollection = GetFakeContactPeople(); parentSelector.SelectedBusinessObject = address.ContactPerson; BOColSelectorLinker <FakeContactPerson, FakeAddress> selectorLinker = new BOColSelectorLinker <FakeContactPerson, FakeAddress>(parentSelector, childSelector, relationshipName); //---------------Assert Precondition---------------- Assert.AreEqual(3, parentSelector.NoOfItems, "Two departments and Blank Field"); Assert.AreSame(address.ContactPerson, parentSelector.SelectedBusinessObject); //---------------Execute Test ---------------------- selectorLinker.UpdateChildSelectorCollection(); //---------------Test Result ----------------------- Assert.AreSame(address.ContactPerson, parentSelector.SelectedBusinessObject); Assert.AreEqual(2, childSelector.NoOfItems, "The Blank Item and the address"); Assert.AreSame(address, childSelector.SelectedBusinessObject); }
public void Test_UpdateChildSelectorCollection_WhenSpecificChildWasSelectedBeforeHand_ShouldRetainSelectedChild() { //---------------Set up test pack------------------- CreateFakeContactPersonWithNoFakeAddress(); var contactPerson = CreateFakeContactPersonWithManyAddresses(); var parentSelector = CreateControl(); var childSelector = CreateControl(); const string relationshipName = "Addresses"; parentSelector.BusinessObjectCollection = GetFakeContactPeople(); var originallySelectedAddress = contactPerson.Addresses[1]; BOColSelectorLinker<FakeContactPerson, FakeAddress> selectorLinker = new BOColSelectorLinker<FakeContactPerson, FakeAddress>(parentSelector, childSelector, relationshipName); parentSelector.SelectedBusinessObject = contactPerson; selectorLinker.UpdateChildSelectorCollection(); childSelector.SelectedBusinessObject = originallySelectedAddress; //---------------Assert Precondition---------------- Assert.AreSame(originallySelectedAddress, childSelector.SelectedBusinessObject); //---------------Execute Test ---------------------- selectorLinker.UpdateChildSelectorCollection(); //---------------Test Result ----------------------- Assert.AreSame(originallySelectedAddress, childSelector.SelectedBusinessObject); }
public void Test_UpdateChildSelectorCollection_WhenSomethingIsSelectedBeforeHand_ShouldUpdateChildSelector() { //---------------Set up test pack------------------- CreateFakeContactPersonWithNoFakeAddress(); var address = CreateFakeAddressWithFakeContactPerson(); var parentSelector = CreateControl(); var childSelector = CreateControl(); const string relationshipName = "Addresses"; parentSelector.BusinessObjectCollection = GetFakeContactPeople(); parentSelector.SelectedBusinessObject = address.ContactPerson; BOColSelectorLinker<FakeContactPerson, FakeAddress> selectorLinker = new BOColSelectorLinker<FakeContactPerson, FakeAddress>(parentSelector, childSelector, relationshipName); //---------------Assert Precondition---------------- Assert.AreEqual(3, parentSelector.NoOfItems, "Two departments and Blank Field"); Assert.AreSame(address.ContactPerson, parentSelector.SelectedBusinessObject); //---------------Execute Test ---------------------- selectorLinker.UpdateChildSelectorCollection(); //---------------Test Result ----------------------- Assert.AreSame(address.ContactPerson, parentSelector.SelectedBusinessObject); Assert.AreEqual(2, childSelector.NoOfItems, "The Blank Item and the address"); Assert.AreSame(address, childSelector.SelectedBusinessObject); }