public async void IncreaseKarmaTest() { // New user, karma should be 1. int karama = await uut.IncreaseKarma(user1Name); Assert.AreEqual(1, karama); Assert.AreEqual(1, await uut.QueryKarma(user1Name)); karama = await uut.IncreaseKarma(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.IncreaseKarma(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.IncreaseKarma(user1Name); Assert.AreEqual(4, karama); Assert.AreEqual(4, await uut.QueryKarma(user1Name)); }
public void IncreaseKarmaMultiUserTest() { // New user, karma should be 1. int karama = uut.IncreaseKarma(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.IncreaseKarma(user2Name).Result; Assert.AreEqual(1, karama); Assert.AreEqual(1, uut.QueryKarma(user2Name).Result); // user 1 should be increaesd, but no user 2. karama = uut.IncreaseKarma(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.IncreaseKarma(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.IncreaseKarma(user1Name).Result; Assert.AreEqual(4, karama); Assert.AreEqual(4, uut.QueryKarma(user1Name).Result); Assert.AreEqual(1, uut.QueryKarma(user2Name).Result); }