コード例 #1
0
        public void TestUpdate()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO cp = GetContactPerson();

            DataStoreInMemory     dataStore = new DataStoreInMemory();
            IBusinessObjectLoader loader    = new BusinessObjectLoaderInMemory(dataStore);
            ITransactionCommitter firstTransactionCommitter = new TransactionCommitterInMemory(dataStore);

            firstTransactionCommitter.AddBusinessObject(cp);
            firstTransactionCommitter.CommitTransaction();

            //---------------Execute Test ----------------------
            cp.Surname = Guid.NewGuid().ToString("N");
            ITransactionCommitter secondTransactionCommitter = new TransactionCommitterInMemory(dataStore);

            secondTransactionCommitter.AddBusinessObject(cp);
            secondTransactionCommitter.CommitTransaction();

            //---------------Test Result -----------------------
            Assert.AreEqual(1, dataStore.Count);
            Assert.AreSame(cp, loader.GetBusinessObject <ContactPersonTestBO>(cp.ID));
            Assert.IsFalse(cp.Status.IsDirty);
            //---------------Tear Down -------------------------
        }
コード例 #2
0
        public void Test_LoadingFromMultipleSources()
        {
            //---------------Set up test pack-------------------

            DataStoreInMemory dataStore1 = new DataStoreInMemory();
            MyBO bo1 = CreateMyBO(dataStore1);
            BusinessObjectLoaderInMemory loader1 = new BusinessObjectLoaderInMemory(dataStore1);

            DataStoreInMemory            dataStore2 = new DataStoreInMemory();
            MyRelatedBo                  bo2        = CreateMyRelatedBO(dataStore2);
            BusinessObjectLoaderInMemory loader2    = new BusinessObjectLoaderInMemory(dataStore2);

            BusinessObjectLoaderInMemory    defaultBusinessObjectLoader     = new BusinessObjectLoaderInMemory(new DataStoreInMemory());
            BusinessObjectLoaderMultiSource businessObjectLoaderMultiSource = new BusinessObjectLoaderMultiSource(defaultBusinessObjectLoader);

            //---------------Execute Test ----------------------
            businessObjectLoaderMultiSource.AddBusinessObjectLoader(typeof(MyBO), loader1);
            businessObjectLoaderMultiSource.AddBusinessObjectLoader(typeof(MyRelatedBo), loader2);
            var loadedBo1 = businessObjectLoaderMultiSource.GetBusinessObject <MyBO>(bo1.ID);
            var loadedBo2 = businessObjectLoaderMultiSource.GetBusinessObject <MyRelatedBo>(bo2.ID);

            //---------------Tear down -------------------------

            Assert.AreSame(loadedBo1, bo1);
            Assert.AreSame(loadedBo2, bo2);
        }
コード例 #3
0
        public void Test_LoadingWithDefaultOnly()
        {
            //---------------Set up test pack-------------------
            DataStoreInMemory dataStore = new DataStoreInMemory();
            MyBO bo1 = CreateMyBO(dataStore);
            BusinessObjectLoaderInMemory defaultBusinessObjectLoader = new BusinessObjectLoaderInMemory(dataStore);

            //---------------Execute Test ----------------------
            BusinessObjectLoaderMultiSource businessObjectLoaderMultiSource = new BusinessObjectLoaderMultiSource(defaultBusinessObjectLoader);
            var loadedBo1 = businessObjectLoaderMultiSource.GetBusinessObject<MyBO>(bo1.ID);
            //---------------Test Result -----------------------
            Assert.AreSame(loadedBo1, bo1);
            //---------------Tear down -------------------------
        }
コード例 #4
0
        public void Test_LoadingWithDefaultOnly()
        {
            //---------------Set up test pack-------------------
            DataStoreInMemory dataStore = new DataStoreInMemory();
            MyBO bo1 = CreateMyBO(dataStore);
            BusinessObjectLoaderInMemory defaultBusinessObjectLoader = new BusinessObjectLoaderInMemory(dataStore);

            //---------------Execute Test ----------------------
            BusinessObjectLoaderMultiSource businessObjectLoaderMultiSource = new BusinessObjectLoaderMultiSource(defaultBusinessObjectLoader);
            var loadedBo1 = businessObjectLoaderMultiSource.GetBusinessObject <MyBO>(bo1.ID);

            //---------------Test Result -----------------------
            Assert.AreSame(loadedBo1, bo1);
            //---------------Tear down -------------------------
        }
コード例 #5
0
        public void TestInsert()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO cp = GetContactPerson();

            DataStoreInMemory dataStore = new DataStoreInMemory();
            IBusinessObjectLoader loader = new BusinessObjectLoaderInMemory(dataStore);
            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);
            //---------------Execute Test ----------------------
            transactionCommitter.AddBusinessObject(cp);
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, dataStore.Count);
            Assert.AreSame(cp, loader.GetBusinessObject<ContactPersonTestBO>(cp.ID));
            //---------------Tear Down -------------------------
        }
コード例 #6
0
        public void TestInsert()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO cp = GetContactPerson();

            DataStoreInMemory     dataStore            = new DataStoreInMemory();
            IBusinessObjectLoader loader               = new BusinessObjectLoaderInMemory(dataStore);
            ITransactionCommitter transactionCommitter = new TransactionCommitterInMemory(dataStore);

            //---------------Execute Test ----------------------
            transactionCommitter.AddBusinessObject(cp);
            transactionCommitter.CommitTransaction();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, dataStore.Count);
            Assert.AreSame(cp, loader.GetBusinessObject <ContactPersonTestBO>(cp.ID));
            //---------------Tear Down -------------------------
        }
コード例 #7
0
        public void TestUpdate()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO cp = GetContactPerson();

            DataStoreInMemory dataStore = new DataStoreInMemory();
            IBusinessObjectLoader loader = new BusinessObjectLoaderInMemory(dataStore);
            ITransactionCommitter firstTransactionCommitter = new TransactionCommitterInMemory(dataStore);
            firstTransactionCommitter.AddBusinessObject(cp);
            firstTransactionCommitter.CommitTransaction();

            //---------------Execute Test ----------------------
            cp.Surname = Guid.NewGuid().ToString("N");
            ITransactionCommitter secondTransactionCommitter = new TransactionCommitterInMemory(dataStore);
            secondTransactionCommitter.AddBusinessObject(cp);
            secondTransactionCommitter.CommitTransaction();

            //---------------Test Result -----------------------
            Assert.AreEqual(1, dataStore.Count);
            Assert.AreSame(cp, loader.GetBusinessObject<ContactPersonTestBO>(cp.ID));
            Assert.IsFalse(cp.Status.IsDirty);
            //---------------Tear Down -------------------------
        }
コード例 #8
0
        public void Test_LoadingFromMultipleSources()
        {
            //---------------Set up test pack-------------------

            DataStoreInMemory dataStore1 = new DataStoreInMemory();
            MyBO bo1 = CreateMyBO(dataStore1);
            BusinessObjectLoaderInMemory loader1 = new BusinessObjectLoaderInMemory(dataStore1);

            DataStoreInMemory dataStore2 = new DataStoreInMemory();
            MyRelatedBo bo2 = CreateMyRelatedBO(dataStore2);
            BusinessObjectLoaderInMemory loader2 = new BusinessObjectLoaderInMemory(dataStore2);

            BusinessObjectLoaderInMemory defaultBusinessObjectLoader = new BusinessObjectLoaderInMemory(new DataStoreInMemory());
            BusinessObjectLoaderMultiSource businessObjectLoaderMultiSource = new BusinessObjectLoaderMultiSource(defaultBusinessObjectLoader);

            //---------------Execute Test ----------------------
            businessObjectLoaderMultiSource.AddBusinessObjectLoader(typeof (MyBO), loader1);
            businessObjectLoaderMultiSource.AddBusinessObjectLoader(typeof(MyRelatedBo), loader2);
            var loadedBo1 = businessObjectLoaderMultiSource.GetBusinessObject<MyBO>(bo1.ID);
            var loadedBo2 = businessObjectLoaderMultiSource.GetBusinessObject<MyRelatedBo>(bo2.ID);
            //---------------Tear down -------------------------

            Assert.AreSame(loadedBo1, bo1);
            Assert.AreSame(loadedBo2, bo2);
        }