public async Task TestUpsertOverridesPreviousValue() { var key = GetTuple(1); await TupleView.UpsertAsync(null, GetTuple(1, "foo")); Assert.AreEqual("foo", (await TupleView.GetAsync(null, key)) ![1]);
public async Task TestCommitUpdatesData() { await using var tx = await Client.Transactions.BeginAsync(); await TupleView.UpsertAsync(tx, GetTuple(1, "2")); await tx.CommitAsync(); var res = await TupleView.GetAsync(null, GetTuple(1)); Assert.AreEqual("2", res ![ValCol]);
public async Task TestUpsertGet() { await TupleView.UpsertAsync(null, GetTuple(1, "foo")); var keyTuple = GetTuple(1); var resTuple = (await TupleView.GetAsync(null, keyTuple)) !; Assert.IsNotNull(resTuple); Assert.AreEqual(2, resTuple.FieldCount); Assert.AreEqual(1L, resTuple["key"]); Assert.AreEqual("foo", resTuple["val"]); }
public async Task TestRecordViewBinaryOperations() { var key = GetTuple(1); await TupleView.UpsertAsync(null, GetTuple(1, "1")); await using var tx = await Client.Transactions.BeginAsync(); await TupleView.UpsertAsync(tx, GetTuple(1, "22")); Assert.IsFalse(await TupleView.DeleteExactAsync(tx, GetTuple(1, "1"))); Assert.IsFalse(await TupleView.InsertAsync(tx, GetTuple(1, "111"))); Assert.AreEqual(GetTuple(1, "22"), await TupleView.GetAsync(tx, key)); Assert.AreEqual(GetTuple(1, "22"), await TupleView.GetAndUpsertAsync(tx, GetTuple(1, "33"))); Assert.AreEqual(GetTuple(1, "33"), await TupleView.GetAndReplaceAsync(tx, GetTuple(1, "44"))); Assert.IsTrue(await TupleView.ReplaceAsync(tx, GetTuple(1, "55"))); Assert.AreEqual(GetTuple(1, "55"), await TupleView.GetAndDeleteAsync(tx, key)); Assert.IsFalse(await TupleView.DeleteAsync(tx, key)); await TupleView.UpsertAllAsync(tx, new[] { GetTuple(1, "6"), GetTuple(2, "7") }); Assert.AreEqual(2, (await TupleView.GetAllAsync(tx, new[] { key, GetTuple(2), GetTuple(3) })).Count); var insertAllRes = await TupleView.InsertAllAsync(tx, new[] { GetTuple(1, "8"), GetTuple(3, "9") }); Assert.AreEqual(GetTuple(1, "6"), await TupleView.GetAsync(tx, key)); Assert.AreEqual(GetTuple(1, "8"), insertAllRes.Single()); Assert.IsFalse(await TupleView.ReplaceAsync(tx, GetTuple(-1))); Assert.IsTrue(await TupleView.ReplaceAsync(tx, GetTuple(1, "10"))); Assert.AreEqual(GetTuple(1, "10"), await TupleView.GetAsync(tx, key)); Assert.IsFalse(await TupleView.ReplaceAsync(tx, GetTuple(1, "1"), GetTuple(1, "11"))); Assert.IsTrue(await TupleView.ReplaceAsync(tx, GetTuple(1, "10"), GetTuple(1, "12"))); Assert.AreEqual(GetTuple(1, "12"), await TupleView.GetAsync(tx, key)); var deleteAllRes = await TupleView.DeleteAllAsync(tx, new[] { GetTuple(3), GetTuple(4) }); Assert.AreEqual(4, deleteAllRes.Single()[0]); Assert.IsNull(await TupleView.GetAsync(tx, GetTuple(3))); var deleteAllExactRes = await TupleView.DeleteAllAsync(tx, new[] { GetTuple(1, "12"), GetTuple(5) }); Assert.AreEqual(5, deleteAllExactRes.Single()[0]); Assert.IsNull(await TupleView.GetAsync(tx, key)); await tx.RollbackAsync(); Assert.AreEqual(GetTuple(1, "1"), await TupleView.GetAsync(null, key)); }