コード例 #1
0
        public void AfterPushChangesDoAppear()
        {
            using (TemporaryWorkbook workbook = new TemporaryWorkbook()) {
                ChangeCoordinator<Account> a = workbook.CreateAccount(AccountType.Asset);
                a.EditableItem.Name = "Fred";
                Guid id = a.EditableItem.AccountID;
                a.PushChanges();

                Asset loaded = workbook.FetchAsset(id);

                Assert.IsNotNull(loaded);
                Assert.AreEqual("Fred", loaded.Name);

                ChangeCoordinator<Asset> loadedLock = workbook.AcquireChangeCoordinator(loaded);
                loadedLock.EditableItem.Name = "Tom";

                // Now, check that the original item ("loaded") is still "Fred" and not "Tom"
                Assert.AreEqual("Fred", loaded.Name);
                Assert.AreEqual("Tom", loadedLock.EditableItem.Name);

                loadedLock.PushChanges();

                Assert.AreEqual("Tom", loaded.Name);
            }
        }
コード例 #2
0
        public void CreateAccountsReferencesEqualTest()
        {
            using (TemporaryWorkbook workbook = new TemporaryWorkbook())
            {
                ChangeCoordinator<Asset> a1 = workbook.CreateAsset();
                Assert.AreNotEqual(a1.EditableItem.AccountID, Guid.Empty);

                Asset a2 = workbook.FetchAsset(a1.EditableItem.AccountID);
                Assert.AreEqual(a1.EditableItem.AccountID, a2.AccountID);
                Assert.IsTrue(object.ReferenceEquals(a1.EditableItem, a2));
            }
        }
コード例 #3
0
        public void EditAfterFetchingWorks()
        {
            using (TemporaryWorkbook workbook = new TemporaryWorkbook()) {
                ChangeCoordinator<Account> a = workbook.CreateAccount(AccountType.Asset);
                a.EditableItem.Name = "Fred";
                Guid id = a.EditableItem.AccountID;
                a.PushChanges();

                Asset loaded = workbook.FetchAsset(id);

                Assert.IsNotNull(loaded);
                Assert.AreEqual("Fred", loaded.Name);

                ChangeCoordinator<Asset> loadedLock = workbook.AcquireChangeCoordinator(loaded);
                loadedLock.EditableItem.Name = "Tom";
                loadedLock.PushChanges();
            }
        }
コード例 #4
0
        public void EditOutsideChangeCoordinatorThrowsException()
        {
            using (TemporaryWorkbook workbook = new TemporaryWorkbook()) {
                ChangeCoordinator<Account> a = workbook.CreateAccount(AccountType.Asset);
                a.EditableItem.Name = "Fred";
                Guid id = a.EditableItem.AccountID;
                a.PushChanges();

                Asset loaded = workbook.FetchAsset(id);
                Assert.IsNotNull(loaded);

                loaded.Name = "Fred";
            }
        }