public void CanListEntities() { // Arrange var conn = GetConnectionString(); var repo = new SqliteUserRepository(conn); var entity = new User(0, "email", new byte[] { 0x1, 0x2 }, "Name"); var savedEntity = repo.AddOrUpdate(entity); // Act var listEntities = repo.ListEntities(); // Assert Assert.IsTrue(listEntities.IsValid); Assert.IsTrue(listEntities.Value.Any()); Assert.IsTrue(savedEntity.Value.Equals(listEntities.Value.First())); }
public void CanListEntitiesByIdAndNameNotFound() { // Arrange var conn = GetConnectionString(); var repo = new SqliteUserRepository(conn); var entity1 = new User(0, "email1", new byte[] { 0x1, 0x1 }, "Name1", "Surname1", false, false); var entity2 = new User(0, "email2", new byte[] { 0x2, 0x2 }, "Name2", "Surname2", true, true); repo.AddOrUpdate(entity1); repo.AddOrUpdate(entity2); var filters = ImmutableList.Create(new[] { new Filter <User>("Id", (uint)1), new Filter <User>("Name", "Name2") }); // Act var listEntities = repo.ListEntities(filters); // Assert Assert.IsTrue(listEntities.IsValid); Assert.IsFalse(listEntities.Value.Any()); }
public void CanListEntitiesActive() { // Arrange var conn = GetConnectionString(); var repo = new SqliteUserRepository(conn); var entity1 = new User(0, "email1", new byte[] { 0x1, 0x2 }, "Name1", isActive: true); var savedEntity1 = repo.AddOrUpdate(entity1); var entity2 = new User(0, "email2", new byte[] { 0x2, 0x1 }, "Name2", isActive: false); _ = repo.AddOrUpdate(entity2); // Act var listEntities = repo.ListEntities(status: Status.Active); // Assert Assert.IsTrue(listEntities.IsValid); Assert.IsTrue(listEntities.Value.Count == 1); Assert.IsTrue(savedEntity1.Value.Equals(listEntities.Value.First())); }
public void CanListEntitiesByEmail() { // Arrange var conn = GetConnectionString(); var repo = new SqliteUserRepository(conn); var entity1 = new User(0, "email1", new byte[] { 0x1, 0x1 }, "Name1", "Surname1", false, false); var entity2 = new User(0, "email2", new byte[] { 0x2, 0x2 }, "Name2", "Surname2", true, true); repo.AddOrUpdate(entity1); var savedEntity2 = repo.AddOrUpdate(entity2); var filters = ImmutableList.Create(new Filter <User>("Email", "email2")); // Act var listEntities = repo.ListEntities(filters); // Assert Assert.IsTrue(listEntities.IsValid); Assert.IsTrue(listEntities.Value.Any()); Assert.IsTrue(savedEntity2.Value.Equals(listEntities.Value.First())); }