Example #1
0
        public async Task TestDeleteExactSameKeyAndValueReturnsTrueDeletesRecord()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            Assert.IsTrue(await PocoView.DeleteExactAsync(null, GetPoco(1, "1")));
            Assert.IsNull(await PocoView.GetAsync(null, GetPoco(1)));
        }
Example #2
0
        public async Task TestDeleteExistingRecordReturnsTrue()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            Assert.IsTrue(await PocoView.DeleteAsync(null, GetPoco(1)));
            Assert.IsNull(await PocoView.GetAsync(null, GetPoco(1)));
        }
Example #3
0
        public async Task TestDeleteExactExistingKeyDifferentValueReturnsFalseDoesNotDelete()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            Assert.IsFalse(await PocoView.DeleteExactAsync(null, GetPoco(1)));
            Assert.IsFalse(await PocoView.DeleteExactAsync(null, GetPoco(1, "2")));
            Assert.IsNotNull(await PocoView.GetAsync(null, GetPoco(1)));
        }
Example #4
0
        public async Task TestReplaceExactExistingRecordWithSameValueReturnsTrueReplacesOld()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            bool res = await PocoView.ReplaceAsync(null, GetPoco(1, "1"), GetPoco(1, "22"));

            Assert.IsTrue(res);
            Assert.AreEqual("22", (await PocoView.GetAsync(null, GetPoco(1))) !.Val);
        }
Example #5
0
        public async Task TestReplaceExactExistingRecordWithDifferentValueReturnsFalseDoesNotReplace()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            bool res = await PocoView.ReplaceAsync(null, GetPoco(1, "11"), GetPoco(1, "22"));

            Assert.IsFalse(res);
            Assert.AreEqual("1", (await PocoView.GetAsync(null, GetPoco(1))) !.Val);
        }
Example #6
0
        public async Task TestReplaceExistingRecordReturnsTrueOverwrites()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            bool res = await PocoView.ReplaceAsync(null, GetPoco(1, "2"));

            Assert.IsTrue(res);
            Assert.AreEqual("2", (await PocoView.GetAsync(null, GetPoco(1))) !.Val);
        }
Example #7
0
        public async Task TestInsertExistingKeyDoesNotOverwriteReturnsFalse()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            var res = await PocoView.InsertAsync(null, GetPoco(1, "2"));

            Assert.IsFalse(res);
            Assert.AreEqual("1", (await PocoView.GetAsync(null, GetPoco(1))) !.Val);
        }
Example #8
0
        public async Task TestGetAndReplaceExistingRecordReturnsOldOverwrites()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "1"));

            Poco?res = await PocoView.GetAndReplaceAsync(null, GetPoco(1, "2"));

            Assert.IsNotNull(res);
            Assert.AreEqual("1", res !.Val);
            Assert.AreEqual("2", (await PocoView.GetAsync(null, GetPoco(1))) !.Val);
        }
Example #9
0
        public async Task TestGetAndUpsertExistingRecordOverwritesAndReturns()
        {
            await PocoView.UpsertAsync(null, GetPoco(2, "2"));

            Poco?res = await PocoView.GetAndUpsertAsync(null, GetPoco(2, "22"));

            Assert.IsNotNull(res);
            Assert.AreEqual(2, res !.Key);
            Assert.AreEqual("2", res.Val);
            Assert.AreEqual("22", (await PocoView.GetAsync(null, GetPoco(2))) !.Val);
        }
Example #10
0
        public async Task TestGetAndDeleteExistingRecordRemovesAndReturns()
        {
            await PocoView.UpsertAsync(null, GetPoco(2, "2"));

            Poco?res = await PocoView.GetAndDeleteAsync(null, GetPoco(2));

            Assert.IsNotNull(res);
            Assert.AreEqual(2, res !.Key);
            Assert.AreEqual("2", res.Val);
            Assert.IsNull(await PocoView.GetAsync(null, GetPoco(2)));
        }
Example #11
0
        public async Task TestUpsertOverridesPreviousValue()
        {
            var key = GetPoco(1);

            await PocoView.UpsertAsync(null, GetPoco(1, "foo"));

            Assert.AreEqual("foo", (await PocoView.GetAsync(null, key)) !.Val);

            await PocoView.UpsertAsync(null, GetPoco(1, "bar"));

            Assert.AreEqual("bar", (await PocoView.GetAsync(null, key)) !.Val);
        }
Example #12
0
        public async Task TestUpsertGet()
        {
            await PocoView.UpsertAsync(null, GetPoco(1, "foo"));

            var keyTuple = GetPoco(1);
            var resTuple = (await PocoView.GetAsync(null, keyTuple)) !;

            Assert.IsNotNull(resTuple);

            Assert.AreEqual(1L, resTuple.Key);
            Assert.AreEqual("foo", resTuple.Val);

            Assert.IsNull(resTuple.UnmappedStr);
            Assert.AreEqual(default(Guid), resTuple.UnmappedId);
        }