public void LockPurchaseOrderDetailTest() { var testUser = GetTestUser(); var testCompany = GetTestCompany(testUser, true); // Create a record var poh = GetTestPurchaseOrderHeader(testCompany, testUser, 1); // Get the first detail record var detailList = PurchasingService.FindPurchaseOrderDetailListModel(poh); var detail = detailList.Items.First(); // Get the current Lock string lockGuid = PurchasingService.LockPurchaseOrderDetail(detail); Assert.IsTrue(!string.IsNullOrEmpty(lockGuid), "Error: Lock record was not found"); // Simulate another user updating the record var otherUser = GetTestUser(); var error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, otherUser, lockGuid); Assert.IsTrue(!error.IsError, error.Message); // Now get the first user to update the record error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, testUser, lockGuid); Assert.IsTrue(error.IsError, "Error: The lock should have caused an error as it has changed"); // Try to update with the new lock lockGuid = PurchasingService.LockPurchaseOrderDetail(detail); error = PurchasingService.InsertOrUpdatePurchaseOrderDetail(detail, testUser, lockGuid); Assert.IsTrue(!error.IsError, $"Error: {error.Message}"); }