public async Task GetByChannel() { var db = new SqliteInMemoryDatabase(); var rm = new DatabaseReminders(db); var t = DateTime.UtcNow + TimeSpan.FromMinutes(1); var r = await rm.Create(t, "pre", "msg", 17, 28); var rs = await rm.Get(channel : 17).ToArrayAsync(); Assert.AreEqual(r, rs.Single()); }
public async Task CreateReminderDoesNotThrow() { var db = new SqliteInMemoryDatabase(); var rm = new DatabaseReminders(db); var t = DateTime.UtcNow + TimeSpan.FromMinutes(1); var r = await rm.Create(t, "pre", "msg", 17, 28); Assert.AreEqual(t, r.TriggerTime); Assert.AreEqual("pre", r.Prelude); Assert.AreEqual("msg", r.Message); Assert.AreEqual(17u, r.ChannelId); Assert.AreEqual(28u, r.UserId); }
public async Task GetByMaxTime() { var db = new SqliteInMemoryDatabase(); var rm = new DatabaseReminders(db); var t = DateTime.UtcNow; var r1 = await rm.Create(t, "pre", "msg2", 17, 28); var r2 = await rm.Create(t + TimeSpan.FromHours(1), "pre", "msg2", 17, 28); var rs = await rm.Get(before : t + TimeSpan.FromHours(0.5f)).ToArrayAsync(); Assert.AreEqual(r1, rs.Single()); }
public async Task Delete() { var db = new SqliteInMemoryDatabase(); var rm = new DatabaseReminders(db); var t = DateTime.UtcNow + TimeSpan.FromMinutes(1); var r = await rm.Create(t, "pre", "msg", 17, 28); Assert.IsTrue(await rm.Delete(28, r.ID)); var rs = await rm.Get(channel : 17).ToArrayAsync(); Assert.AreEqual(0, rs.Length); }
public async Task GetWithLimit() { var db = new SqliteInMemoryDatabase(); var rm = new DatabaseReminders(db); var t = DateTime.UtcNow; for (var i = 0; i < 10; i++) { await rm.Create(t + TimeSpan.FromMinutes(i), "pre", "msg " + i, 17, 28); } var rs = await rm.Get(channel : 17, count : 3).ToArrayAsync(); Assert.AreEqual(3, rs.Length); Assert.AreEqual((t + TimeSpan.FromMinutes(0)).UnixTimestamp(), rs[0].TriggerTime.UnixTimestamp()); Assert.AreEqual((t + TimeSpan.FromMinutes(1)).UnixTimestamp(), rs[1].TriggerTime.UnixTimestamp()); Assert.AreEqual((t + TimeSpan.FromMinutes(2)).UnixTimestamp(), rs[2].TriggerTime.UnixTimestamp()); }