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); } }
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)); } }
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(); } }
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"; } }