public async Task NonExistingStatusIsNotFetchedForColumn() { // Arrange using (var con = OpenConnection()) using (var cache = new SqliteCache(con)) { var status = DummyGenerator.CreateDummyStatus(); status.ID = 123; var colId = Guid.NewGuid(); await cache.AddStatuses(new[] { status }); await cache.MapStatusesToColumn(new[] { status }, colId); // Act var beforeDelete = await cache.GetStatusesForColumn(colId, 1); await cache.RemoveStatus(status.ID); var afterDelete = await cache.GetStatusesForColumn(colId, 1); // Assert Assert.AreEqual(1, beforeDelete.Count); Assert.AreEqual(0, afterDelete.Count); } }
public async Task StatusesForColumnCanBeLoaded() { // Arrange using (var con = OpenConnection()) using (var cache = new SqliteCache(con)) { var user = DummyGenerator.CreateDummyUser(); user.UserID = 123; var s1 = DummyGenerator.CreateDummyStatus(user); s1.ID = 1; var s2 = DummyGenerator.CreateDummyStatus(user); s2.ID = 2; var s3 = DummyGenerator.CreateDummyStatus(user); s3.ID = 3; await cache.AddStatuses(new[] { s1, s2, s3 }); var c1 = Guid.NewGuid(); var c2 = Guid.NewGuid(); using (var cmd = con.CreateCommand()) { cmd.CommandText = "INSERT INTO ColumnStatuses (ColumnId, StatusId) VALUES (@c1, 1), (@c1, 2), (@c2, 3);"; cmd.AddParameter("c1", c1); cmd.AddParameter("c2", c2); cmd.ExecuteNonQuery(); } // Act var statusesC1 = (await cache.GetStatusesForColumn(c1, 999)).ToArray(); var statusesC2 = (await cache.GetStatusesForColumn(c2, 999)).ToArray(); // Assert Assert.AreEqual(2, statusesC1.Length); Assert.IsNotNull(statusesC1.SingleOrDefault(s => s.ID == 1)); Assert.IsNotNull(statusesC1.SingleOrDefault(s => s.ID == 2)); Assert.AreEqual(1, statusesC2.Length); Assert.IsNotNull(statusesC2.SingleOrDefault(s => s.ID == 3)); } }
public async Task CleanupRemovesColumnMappings() { // Arrange using (var con = OpenConnection()) using (var cache = new SqliteCache(con)) { var status = DummyGenerator.CreateDummyStatus(); status.ID = 123; var colId = Guid.NewGuid(); await cache.MapStatusesToColumn(new[] { status }, colId); // Act var statuses = await cache.GetStatusesForColumn(colId, 1); // Assert Assert.AreEqual(0, statuses.Count); } }