Exemple #1
0
        public async void DecreaseKarmaTest()
        {
            // New user, karma should be 1.
            int karama = await uut.DecreaseKarma(user1Name);

            Assert.AreEqual(-1, karama);
            Assert.AreEqual(-1, await uut.QueryKarma(user1Name));

            karama = await uut.DecreaseKarma(user1Name);

            Assert.AreEqual(-2, karama);
            Assert.AreEqual(-2, await uut.QueryKarma(user1Name));

            // Dispose and reopen.
            this.uut.Dispose();
            this.uut = new KarmaBotDatabase(databaseName);

            karama = await uut.DecreaseKarma(user1Name);

            Assert.AreEqual(-3, karama);
            Assert.AreEqual(-3, await uut.QueryKarma(user1Name));

            // Dispose and reopen.
            this.uut.Dispose();
            this.uut = new KarmaBotDatabase(databaseName);

            // Ensure querying is okay.
            Assert.AreEqual(-3, await uut.QueryKarma(user1Name));

            // One more increase, since why not?
            karama = await uut.DecreaseKarma(user1Name);

            Assert.AreEqual(-4, karama);
            Assert.AreEqual(-4, await uut.QueryKarma(user1Name));
        }
Exemple #2
0
        public void DecreaseKarmaMultiUserTest()
        {
            // New user, karma should be 1.
            int karama = uut.DecreaseKarma(user1Name).Result;

            Assert.AreEqual(-1, karama);
            Assert.AreEqual(-1, uut.QueryKarma(user1Name).Result);

            // New User, karma should be 1.
            Assert.AreEqual(0, uut.QueryKarma(user2Name).Result);
            karama = uut.DecreaseKarma(user2Name).Result;
            Assert.AreEqual(-1, karama);
            Assert.AreEqual(-1, uut.QueryKarma(user2Name).Result);

            // user 1 should be increaesd, but no user 2.
            karama = uut.DecreaseKarma(user1Name).Result;
            Assert.AreEqual(-2, karama);
            Assert.AreEqual(-2, uut.QueryKarma(user1Name).Result);
            Assert.AreEqual(-1, uut.QueryKarma(user2Name).Result);

            // Dispose and reopen.
            this.uut.Dispose();
            this.uut = new KarmaBotDatabase(databasePath);

            karama = uut.DecreaseKarma(user1Name).Result;
            Assert.AreEqual(-3, karama);
            Assert.AreEqual(-3, uut.QueryKarma(user1Name).Result);

            // User 2 should be the same
            Assert.AreEqual(-1, uut.QueryKarma(user2Name).Result);

            // Dispose and reopen.
            this.uut.Dispose();
            this.uut = new KarmaBotDatabase(databasePath);

            // Ensure querying is okay.
            Assert.AreEqual(-3, uut.QueryKarma(user1Name).Result);
            Assert.AreEqual(-1, uut.QueryKarma(user2Name).Result);

            // One more increase, since why not?
            karama = uut.DecreaseKarma(user1Name).Result;
            Assert.AreEqual(-4, karama);
            Assert.AreEqual(-4, uut.QueryKarma(user1Name).Result);
            Assert.AreEqual(-1, uut.QueryKarma(user2Name).Result);
        }