public void Test_ChangeParentSelectedIndex_WithNonEmpty_ShouldLoadChildren()
        {
            //---------------Set up test pack-------------------
            var contactPersonNoAddress = CreateFakeContactPersonWithNoFakeAddress();

            CreateFakeAddressWithFakeContactPerson();

            IBOComboBoxSelector parentSelector   = CreateComboBoxControl();
            IBOComboBoxSelector childSelector    = CreateComboBoxControl();
            const string        relationshipName = "Addresses";

            new BOColSelectorLinker <FakeContactPerson, FakeAddress>(parentSelector, childSelector, relationshipName);
            parentSelector.BusinessObjectCollection = GetFakeContactPeople();
            parentSelector.SelectedBusinessObject   = contactPersonNoAddress;
            //---------------Assert Precondition----------------
            Assert.AreEqual(3, parentSelector.NoOfItems, "Two departments and Blank Field");
            Assert.AreSame(contactPersonNoAddress, parentSelector.SelectedBusinessObject);
            Assert.AreEqual(1, childSelector.NoOfItems, "The Blank Item");
            //---------------Execute Test ----------------------
            parentSelector.SelectedIndex = 1;
            //---------------Test Result -----------------------
            Assert.IsNotNull(parentSelector.SelectedBusinessObject);
            FakeContactPerson contactPerson = parentSelector.SelectedBusinessObject as FakeContactPerson;

            Assert.AreEqual(contactPerson.Addresses.Count + 1, childSelector.NoOfItems);
        }
        protected static FakeContactPerson CreateFakeContactPersonWithManyAddresses()
        {
            var savedContactPerson = FakeContactPerson.CreateSavedContactPerson();

            FakeAddress.CreateSavedAddress(savedContactPerson);
            FakeAddress.CreateSavedAddress(savedContactPerson);
            FakeAddress.CreateSavedAddress(savedContactPerson);
            return(savedContactPerson);
        }
        public static FakeAddress CreateSavedAddress(FakeContactPerson contactPerson)
        {
            var fakeAddress = new FakeAddress {
                ContactPerson = contactPerson
            };

            fakeAddress.Save();
            return(fakeAddress);
        }
 protected static FakeContactPerson CreateFakeContactPersonWithNoFakeAddress()
 {
     return(FakeContactPerson.CreateSavedContactPerson());
 }
 protected static FakeAddress CreateFakeAddressWithFakeContactPerson()
 {
     return(FakeAddress.CreateSavedAddress(FakeContactPerson.CreateSavedContactPerson()));
 }
 public static FakeAddress CreateSavedAddress(FakeContactPerson contactPerson)
 {
     var fakeAddress = new FakeAddress {ContactPerson = contactPerson};
     fakeAddress.Save();
     return fakeAddress;
 }