public void Test_NonAutoLoading_SetPerson_WithUnsavedOrganisation_ShouldNotRemoveOrganisation_FIXBUG()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            BusinessObjectCollection <OrganisationTestBO> boCol;
            RelationshipComboBoxMapper mapper = new RelationshipComboBoxMapper(cmbox, "Organisation", false,
                                                                               GlobalUIRegistry.ControlFactory);

            boCol = GetBoColWithOneItem();
            mapper.BusinessObjectCollection = boCol;
            mapper.BusinessObject           = new ContactPersonTestBO();

            OrganisationTestBO  testBO = new OrganisationTestBO();
            ContactPersonTestBO person = CreateCPWithRelatedOrganisation(testBO);

            //---------------Assert Precondition----------------
            Assert.False(boCol.Contains(testBO));
            Assert.AreSame(testBO, person.Organisation);
            Assert.IsNotNull(person.Organisation);
            Assert.IsTrue(person.Organisation.Status.IsNew);
            //---------------Execute Test ----------------------
            mapper.BusinessObject = person;
            //---------------Test Result -----------------------
            Assert.IsNotNull(person.Organisation);
        }
        public void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub          cmbox    = new ComboBoxWinStub();
            const string             propName = "SampleLookupID";
            CollectionComboBoxMapper mapper   = new CollectionComboBoxMapper(cmbox, propName, false, GetControlFactory())
            {
                MapperStrategy =
                    GetControlFactory().CreateLookupKeyPressMapperStrategy()
            };
            Car car1;
            Car car2;

            mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
            Sample s = new Sample {
                SampleLookupID = car1.CarID
            };

            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.Text = car2.ToString();
            cmbox.CallSendKeyBob();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual(car2.CarID, s.SampleLookupID);
        }
        public void TestKeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub      cmbox    = new ComboBoxWinStub();
            const string         propName = "SampleLookupID";
            LookupComboBoxMapper mapper   = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());
            Sample s = new Sample();

            mapper.LookupList     = Sample.LookupCollection;
            s.SampleLookupID      = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.Text = "Test2";
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxDefaultMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID);
        }
        public void TestKeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub          cmbox    = new ComboBoxWinStub();
            const string             propName = "SampleLookupID";
            CollectionComboBoxMapper mapper   = new CollectionComboBoxMapper(cmbox, propName, false, GetControlFactory());
            Car car1;
            Car car2;

            mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
            Sample s = new Sample {
                SampleLookupID = car1.CarID
            };

            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.Text = car2.ToString();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxDefaultMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual(car2.CarID, s.SampleLookupID);
        }
        public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub      cmbox    = new ComboBoxWinStub();
            const string         propName = "SampleLookupID";
            LookupComboBoxMapper mapper   = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());

            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            Sample s = new Sample();

            mapper.LookupList     = Sample.LookupCollection;
            s.SampleLookupID      = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.SelectedItem = LOOKUP_ITEM_2;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1), s.SampleLookupID);
            //---------------Tear Down -------------------------
        }
        public void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub      cmbox    = new ComboBoxWinStub();
            const string         propName = "SampleLookupID";
            LookupComboBoxMapper mapper   = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());

            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            Sample s = new Sample();

            mapper.LookupList     = Sample.LookupCollection;
            s.SampleLookupID      = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.Text = "Test2";
            cmbox.CallSendKeyBob();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID);
        }
        public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged()
        {
            //---------------Set up test pack-------------------

            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            BusinessObjectCollection <OrganisationTestBO> boCol;
            RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol);

            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            OrganisationTestBO  newBO = boCol.CreateBusinessObject();
            OrganisationTestBO  organisationTestBO = boCol[0];
            ContactPersonTestBO person             = CreateCPWithRelatedOrganisation(organisationTestBO);

            mapper.BusinessObject = person;
            //---------------Execute Test ----------------------
            cmbox.SelectedItem = newBO;
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed.");
            Assert.AreSame(organisationTestBO, person.Organisation, "For Windows the value should be changed.");
        }
예제 #8
0
        public override void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            BusinessObjectCollection <OrganisationTestBO> boCol;
            RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol);

            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            OrganisationTestBO newBO = boCol.CreateBusinessObject();

            newBO.Save();
            OrganisationTestBO  organisationTestBO = boCol[0];
            ContactPersonTestBO person             = CreateCPWithRelatedOrganisation(organisationTestBO);

            mapper.BusinessObject = person;
            cmbox.Text            = newBO.ToString();
            //---------------Assert Precondition----------------
            Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed.");
            //---------------Execute Test ----------------------
            cmbox.CallSendKeyBob();
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreSame(newBO, person.Organisation, "For Windows the value should be changed.");
        }
        public void Test_NonAutoLoading_SetPerson_WithUnsavedOrganisation_ShouldNotRemoveOrganisation_FIXBUG()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            BusinessObjectCollection<OrganisationTestBO> boCol;
            RelationshipComboBoxMapper mapper = new RelationshipComboBoxMapper(cmbox, "Organisation", false,
                                                                                   GlobalUIRegistry.ControlFactory);
            boCol = GetBoColWithOneItem();
            mapper.BusinessObjectCollection = boCol;
            mapper.BusinessObject = new ContactPersonTestBO();

            OrganisationTestBO testBO = new OrganisationTestBO();
            ContactPersonTestBO person = CreateCPWithRelatedOrganisation(testBO);
            //---------------Assert Precondition----------------
            Assert.False(boCol.Contains(testBO));
            Assert.AreSame(testBO, person.Organisation);
            Assert.IsNotNull(person.Organisation);
            Assert.IsTrue(person.Organisation.Status.IsNew);
            //---------------Execute Test ----------------------
            mapper.BusinessObject = person;
            //---------------Test Result -----------------------
            Assert.IsNotNull(person.Organisation);
        }
        public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged()
        {
            //---------------Set up test pack-------------------

            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            BusinessObjectCollection<OrganisationTestBO> boCol;
            RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol);
            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            OrganisationTestBO newBO = boCol.CreateBusinessObject();
            OrganisationTestBO organisationTestBO = boCol[0];
            ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO);
            mapper.BusinessObject = person;
            //---------------Execute Test ----------------------
            cmbox.SelectedItem = newBO;
            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed.");
            Assert.AreSame(organisationTestBO, person.Organisation, "For Windows the value should be changed.");
        }
 public override void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed()
 {
     //---------------Set up test pack-------------------
     ComboBoxWinStub cmbox = new ComboBoxWinStub();
     BusinessObjectCollection<OrganisationTestBO> boCol;
     RelationshipComboBoxMapper mapper = GetMapperBoColHasOneItem(cmbox, out boCol);
     mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
     OrganisationTestBO newBO = boCol.CreateBusinessObject();
     newBO.Save();
     OrganisationTestBO organisationTestBO = boCol[0];
     ContactPersonTestBO person = CreateCPWithRelatedOrganisation(organisationTestBO);
     mapper.BusinessObject = person;
     cmbox.Text = newBO.ToString();
     //---------------Assert Precondition----------------
     Assert.AreNotSame(newBO, person.Organisation, "For Windows the value should be changed.");
     //---------------Execute Test ----------------------
     cmbox.CallSendKeyBob();
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
     Assert.AreSame(newBO, person.Organisation, "For Windows the value should be changed.");
 }
        public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_SelectedIndexChanged()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            const string propName = "SampleLookupID";
            LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());
            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            Sample s = new Sample();
            mapper.LookupList = Sample.LookupCollection;
            s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.SelectedItem = LOOKUP_ITEM_2;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1), s.SampleLookupID);
            //---------------Tear Down -------------------------
        }
        public void Test_KeyPressStrategy_UpdatesBusinessObject_WhenEnterKeyPressed()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            const string propName = "SampleLookupID";
            LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());
            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            Sample s = new Sample();
            mapper.LookupList = Sample.LookupCollection;
            s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.Text = "Test2";
            cmbox.CallSendKeyBob();

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID);
        }
 public void TestKeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges()
 {
     //---------------Set up test pack-------------------
     ComboBoxWinStub cmbox = new ComboBoxWinStub();
     const string propName = "SampleLookupID";
     LookupComboBoxMapper mapper = new LookupComboBoxMapper(cmbox, propName, false, GetControlFactory());
     Sample s = new Sample();
     mapper.LookupList = Sample.LookupCollection;
     s.SampleLookupID = (Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_1);
     mapper.BusinessObject = s;
     //---------------Execute Test ----------------------
     cmbox.Text = "Test2";
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(ComboBoxDefaultMapperStrategyWin), mapper.MapperStrategy);
     Assert.AreEqual((Guid)GetGuidValue(Sample.LookupCollection, LOOKUP_ITEM_2), s.SampleLookupID);
 }
 public void TestKeyPressEventUpdatesBusinessObject_WithoutCallingApplyChanges()
 {
     //---------------Set up test pack-------------------
     ComboBoxWinStub cmbox = new ComboBoxWinStub();
     const string propName = "SampleLookupID";
     CollectionComboBoxMapper mapper = new CollectionComboBoxMapper(cmbox, propName, false, GetControlFactory());
     Car car1;
     Car car2;
     mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
     Sample s = new Sample { SampleLookupID = car1.CarID };
     mapper.BusinessObject = s;
     //---------------Execute Test ----------------------
     cmbox.Text = car2.ToString();
     //---------------Test Result -----------------------
     Assert.IsInstanceOf(typeof(ComboBoxDefaultMapperStrategyWin), mapper.MapperStrategy);
     Assert.AreEqual(car2.CarID, s.SampleLookupID);
 }
        public void Test_KeyPressStrategy_DoesNotUpdateBusinessObject_When_SelectedIndexChanged()
        {
            //---------------Set up test pack-------------------
            ComboBoxWinStub cmbox = new ComboBoxWinStub();
            const string propName = "SampleLookupID";
            CollectionComboBoxMapper mapper = new CollectionComboBoxMapper(cmbox, propName, false, GetControlFactory());
            mapper.MapperStrategy = GetControlFactory().CreateLookupKeyPressMapperStrategy();
            Car car1;
            Car car2;
            mapper.BusinessObjectCollection = GetCollectionWithTwoCars(out car1, out car2);
            Sample s = new Sample { SampleLookupID = car1.CarID };
            mapper.BusinessObject = s;
            //---------------Execute Test ----------------------
            cmbox.SelectedItem = car2;

            //---------------Test Result -----------------------
            Assert.IsInstanceOf(typeof(ComboBoxKeyPressMapperStrategyWin), mapper.MapperStrategy);
            Assert.AreEqual(car1.CarID, s.SampleLookupID);
        }