Ejemplo n.º 1
0
        public void TestMutableCompositeKeyObject_TwoObjectsWithSameFieldNameAndValueAsPrimaryKey()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BOWithIntID_DifferentType.LoadClassDefWithIntID_CompositeKey();
            BOWithIntID.LoadClassDefWithIntID_WithCompositeKey();
            DataStoreInMemory dataStore = new DataStoreInMemory();

            BORegistry.DataAccessor = new DataAccessorInMemory(dataStore);
            new Car();
            BOWithIntID boWithIntID = new BOWithIntID {
                IntID = TestUtil.GetRandomInt()
            };

            boWithIntID.Save();
            BOWithIntID_DifferentType intID_DifferentType = new BOWithIntID_DifferentType();

            intID_DifferentType.IntID = boWithIntID.IntID;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            intID_DifferentType.Save();
            //---------------Test Result -----------------------
            Assert.AreEqual(2, dataStore.Count);

            Assert.IsTrue(dataStore.AllObjects.ContainsKey(boWithIntID.ID.ObjectID));
            Assert.IsTrue(dataStore.AllObjects.ContainsKey(intID_DifferentType.ID.ObjectID));

            IBusinessObject returnedBOWitID          = dataStore.AllObjects[boWithIntID.ID.ObjectID];
            IBusinessObject returnedBOWitID_diffType = dataStore.AllObjects[intID_DifferentType.ID.ObjectID];

            Assert.AreSame(boWithIntID, returnedBOWitID);
            Assert.AreSame(intID_DifferentType, returnedBOWitID_diffType);
        }
Ejemplo n.º 2
0
        public void Test_MutableKeyObject_TwoObjectsWithSameFieldNameAndValueAsPrimaryKey()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BOWithIntID_DifferentType.LoadClassDefWithIntID();
            BOWithIntID.LoadClassDefWithIntID();
            DataStoreInMemory dataStore = new DataStoreInMemory();

            BORegistry.DataAccessor = new DataAccessorInMemory(dataStore);
            new Car();
            BOWithIntID boWithIntID = new BOWithIntID();

            boWithIntID.IntID = TestUtil.GetRandomInt();
            boWithIntID.Save();
            BOWithIntID_DifferentType intID_DifferentType = new BOWithIntID_DifferentType();

            intID_DifferentType.IntID = TestUtil.GetRandomInt();
            intID_DifferentType.Save();
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, dataStore.Count);
            //---------------Execute Test ----------------------
//            dataStore.Add(intID_DifferentType);
//            // in the save process the ID is updated to the persisted field values, so the hash of the ID changes
//            // this is why the object is removed and re-added to the BusinessObjectManager (to ensure the dictionary
//            // of objects is hashed on the correct, updated value.
//            intID_DifferentType.Save();
            IBusinessObject returnedBOWitID          = dataStore.AllObjects[boWithIntID.ID.ObjectID];
            IBusinessObject returnedBOWitID_diffType = dataStore.AllObjects[intID_DifferentType.ID.ObjectID];

            //---------------Test Result -----------------------
            Assert.AreSame(boWithIntID, returnedBOWitID);
            Assert.AreSame(intID_DifferentType, returnedBOWitID_diffType);
        }
        public void Test_FindFirst_Generic_TwoObjectTypesWithTheSameIDField_HaveSameValue()
        {
            //--------------- Set up test pack ------------------
            BusinessObjectManagerStub.SetNewBusinessObjectManager();
            var boMan = (BusinessObjectManagerStub) BusinessObjectManagerStub.Instance;
            boMan.ClearLoadedObjects();
            BOWithIntID.LoadClassDefWithIntID();
            BOWithIntID_DifferentType.LoadClassDefWithIntID();
            const int id = 3;
            var boWithIntID = new BOWithIntID {IntID = id};
            var boWithIntID_DifferentType = new BOWithIntID_DifferentType {IntID = id};
            //--------------- Test Preconditions ----------------
            Assert.AreEqual(2, boMan.Count);
            Assert.IsTrue(boMan.Contains(boWithIntID_DifferentType));
            Assert.IsTrue(boMan.Contains(boWithIntID));
            //--------------- Execute Test ----------------------
            //BusinessObjectCollection<BOWithIntID> found = boMan.FindFirst<BOWithIntID>(new Criteria("IntID", Criteria.ComparisonOp.Equals, id));
            var criteria = new Criteria("IntID", Criteria.ComparisonOp.Equals, id);
            var found = BusinessObjectManager.Instance.FindFirst(criteria, typeof (BOWithIntID));

            //--------------- Test Result -----------------------
            Assert.IsNotNull(found);
            Assert.AreSame(boWithIntID, found);
            Assert.AreEqual(2, boMan.Count);
            Assert.IsTrue(boMan.Contains(boWithIntID_DifferentType));
            Assert.IsTrue(boMan.Contains(boWithIntID));
        }
     Test_TwoObjectTypesWithTheSameIDField_EditedToHaveTheSamevalue_CanBeAddedToObjectMan_AsString_LastPersistedValue
     ()
 {
     //--------------- Set up test pack ------------------
     BusinessObjectManagerStub.SetNewBusinessObjectManager();
     var boMan = (BusinessObjectManagerStub) BusinessObjectManagerStub.Instance;
     boMan.ClearLoadedObjects();
     BOWithIntID.LoadClassDefWithIntID();
     BOWithIntID_DifferentType.LoadClassDefWithIntID();
     const int id = 3;
     var boWithIntID = new BOWithIntID {IntID = id};
     var boWithIntID_DifferentType = new BOWithIntID_DifferentType {IntID = 6};
     boWithIntID_DifferentType.IntID = boWithIntID.IntID;
     boMan.ClearLoadedObjects();
     //--------------- Test Preconditions ----------------
     Assert.AreEqual(0, boMan.Count);
     //--------------- Execute Test ----------------------
     boMan.AddBusinessObject(boWithIntID, boWithIntID.ID.ObjectID);
     boMan.AddBusinessObject(boWithIntID_DifferentType, boWithIntID_DifferentType.ID.ObjectID);
     //--------------- Test Result -----------------------
     Assert.AreEqual(2, boMan.Count);
     Assert.IsTrue(boMan.Contains(boWithIntID_DifferentType));
     Assert.IsTrue(boMan.Contains(boWithIntID));
 }
 public void Test_TwoObjectTypesWithTheSameIDField_EdidtedToHaveTheSamevalue_CanBeAddedToObjectMan()
 {
     //--------------- Set up test pack ------------------
     var boMan = BusinessObjectManager.Instance;
     boMan.ClearLoadedObjects();
     BOWithIntID.LoadClassDefWithIntID();
     BOWithIntID_DifferentType.LoadClassDefWithIntID();
     const int id = 3;
     var boWithIntID = new BOWithIntID {IntID = id};
     var boWithIntID_DifferentType = new BOWithIntID_DifferentType {IntID = 6};
     //--------------- Test Preconditions ----------------
     Assert.AreEqual(2, boMan.Count);
     //--------------- Execute Test ----------------------
     boWithIntID_DifferentType.IntID = boWithIntID.IntID;
     //--------------- Test Result -----------------------
     Assert.AreEqual(2, boMan.Count);
     Assert.IsTrue(boMan.Contains(boWithIntID_DifferentType));
     Assert.IsTrue(boMan.Contains(boWithIntID));
 }
Ejemplo n.º 6
0
        public void TestMutableCompositeKeyObject_TwoObjectsWithSameFieldNameAndValueAsPrimaryKey()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BOWithIntID_DifferentType.LoadClassDefWithIntID_CompositeKey();
            BOWithIntID.LoadClassDefWithIntID_WithCompositeKey();
            DataStoreInMemory dataStore = new DataStoreInMemory();
            BORegistry.DataAccessor = new DataAccessorInMemory(dataStore);
            new Car();
            BOWithIntID boWithIntID = new BOWithIntID {IntID = TestUtil.GetRandomInt()};
            boWithIntID.Save();
            BOWithIntID_DifferentType intID_DifferentType = new BOWithIntID_DifferentType();
            intID_DifferentType.IntID = boWithIntID.IntID;
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            intID_DifferentType.Save();
            //---------------Test Result -----------------------
            Assert.AreEqual(2, dataStore.Count);

            Assert.IsTrue(dataStore.AllObjects.ContainsKey(boWithIntID.ID.ObjectID));
            Assert.IsTrue(dataStore.AllObjects.ContainsKey(intID_DifferentType.ID.ObjectID));

            IBusinessObject returnedBOWitID = dataStore.AllObjects[boWithIntID.ID.ObjectID];
            IBusinessObject returnedBOWitID_diffType = dataStore.AllObjects[intID_DifferentType.ID.ObjectID];

            Assert.AreSame(boWithIntID, returnedBOWitID);
            Assert.AreSame(intID_DifferentType, returnedBOWitID_diffType);
        }
Ejemplo n.º 7
0
        public void Test_MutableKeyObject_TwoObjectsWithSameFieldNameAndValueAsPrimaryKey()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            BOWithIntID_DifferentType.LoadClassDefWithIntID();
            BOWithIntID.LoadClassDefWithIntID();
            DataStoreInMemory dataStore = new DataStoreInMemory();
            BORegistry.DataAccessor = new DataAccessorInMemory(dataStore);
            new Car();
            BOWithIntID boWithIntID = new BOWithIntID();
            boWithIntID.IntID = TestUtil.GetRandomInt();
            boWithIntID.Save();
            BOWithIntID_DifferentType intID_DifferentType = new BOWithIntID_DifferentType();
            intID_DifferentType.IntID = TestUtil.GetRandomInt();
            intID_DifferentType.Save();
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, dataStore.Count);
            //---------------Execute Test ----------------------
//            dataStore.Add(intID_DifferentType);
//            // in the save process the ID is updated to the persisted field values, so the hash of the ID changes
//            // this is why the object is removed and re-added to the BusinessObjectManager (to ensure the dictionary
//            // of objects is hashed on the correct, updated value.
//            intID_DifferentType.Save();
            IBusinessObject returnedBOWitID = dataStore.AllObjects[boWithIntID.ID.ObjectID];
            IBusinessObject returnedBOWitID_diffType = dataStore.AllObjects[intID_DifferentType.ID.ObjectID];

            //---------------Test Result -----------------------
            Assert.AreSame(boWithIntID, returnedBOWitID);
            Assert.AreSame(intID_DifferentType, returnedBOWitID_diffType);
        }