Пример #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 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();
            }
        }
Пример #3
0
        public void EditAfterPushChangesThrowsException()
        {
            using (TemporaryWorkbook workbook = new TemporaryWorkbook()) {
                ChangeCoordinator<Account> a = workbook.CreateAccount(AccountType.Asset);
                a.EditableItem.Name = "Fred";
                Guid id = a.EditableItem.AccountID;
                a.PushChanges();

                a.EditableItem.Name = "Fred";
            }
        }
Пример #4
0
 public void EditWithinChangeCoordinatorWorks()
 {
     using (TemporaryWorkbook workbook = new TemporaryWorkbook()) {
         ChangeCoordinator<Account> a = workbook.CreateAccount(AccountType.Asset);
         a.EditableItem.Name = "Fred";
     }
 }
Пример #5
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";
            }
        }