public void CanListEntitiesByPage()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo    = new SqliteLanguageRepository(conn);
            var entity1 = new Language(0, "Name1");
            var entity2 = new Language(0, "Name2");
            var entity3 = new Language(0, "Name3");
            var entity4 = new Language(0, "Name4");
            var entity5 = new Language(0, "Name5");

            repo.AddOrUpdate(entity1);
            var savedEntity1 = repo.AddOrUpdate(entity2);
            var savedEntity2 = repo.AddOrUpdate(entity3);

            repo.AddOrUpdate(entity4);
            repo.AddOrUpdate(entity5);

            // Act
            var listEntities = repo.ListEntities(take: 2, skip: 1)
            ;

            // Assert
            Assert.IsTrue(listEntities.IsValid);
            Assert.IsTrue(listEntities.Value.Count == 2);
            Assert.IsTrue(savedEntity1.Value.Equals(listEntities.Value[0]));
            Assert.IsTrue(savedEntity2.Value.Equals(listEntities.Value[1]));
        }
        public void ListEntitiesIsSafe()
        {
            // Arrange
            var conn = GetConnectionString();
            var repo = new SqliteLanguageRepository(conn);

            // Act
            _conn.Dispose();
            var listEntities = repo.ListEntities();

            // Assert
            Assert.IsFalse(listEntities.IsValid);
        }
        public void CanListEntities()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo        = new SqliteLanguageRepository(conn);
            var entity      = new Language(0, "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 CanListEntitiesInactive()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo    = new SqliteLanguageRepository(conn);
            var entity1 = new Language(0, "Name1", true);

            _ = repo.AddOrUpdate(entity1);
            var entity2      = new Language(0, "Name2", false);
            var savedEntity2 = repo.AddOrUpdate(entity2);

            // Act
            var listEntities = repo.ListEntities(status: Status.Inactive);

            // Assert
            Assert.IsTrue(listEntities.IsValid);
            Assert.IsTrue(listEntities.Value.Count == 1);
            Assert.IsTrue(savedEntity2.Value.Equals(listEntities.Value.First()));
        }
        public void CanListEntitiesByIdAndNameNotFound()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo    = new SqliteLanguageRepository(conn);
            var entity1 = new Language(0, "Name1");
            var entity2 = new Language(0, "Name2");

            repo.AddOrUpdate(entity1);
            repo.AddOrUpdate(entity2);
            var filters = ImmutableList.Create(new[] { new Filter <Language>("Id", (uint)1), new Filter <Language>("Name", "Name2") });

            // Act
            var listEntities = repo.ListEntities(filters);

            // Assert
            Assert.IsTrue(listEntities.IsValid);
            Assert.IsFalse(listEntities.Value.Any());
        }
        public void CanListEntitiesByName()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo    = new SqliteLanguageRepository(conn);
            var entity1 = new Language(0, "Name1");
            var entity2 = new Language(0, "Name2");

            repo.AddOrUpdate(entity1);
            var savedEntity2 = repo.AddOrUpdate(entity2);
            var filters      = ImmutableList.Create(new Filter <Language>("Name", "Name2"));

            // Act
            var listEntities = repo.ListEntities(filters);

            // Assert
            Assert.IsTrue(listEntities.IsValid);
            Assert.IsTrue(listEntities.Value.Any());
            Assert.IsTrue(savedEntity2.Value.Equals(listEntities.Value.First()));
        }
        public void CanListEntitiesActiveAndByName()
        {
            // Arrange
            var conn = GetConnectionString();

            var repo         = new SqliteLanguageRepository(conn);
            var entity1      = new Language(0, "Name1", true);
            var savedEntity1 = repo.AddOrUpdate(entity1);
            var entity2      = new Language(0, "Name2", false);

            _ = repo.AddOrUpdate(entity2);
            var filters = ImmutableList.Create(new Filter <Language>("Name", "Name1"));

            // Act
            var listEntities = repo.ListEntities(filters: filters, status: Status.Active);

            // Assert
            Assert.IsTrue(listEntities.IsValid);
            Assert.IsTrue(listEntities.Value.Count == 1);
            Assert.IsTrue(savedEntity1.Value.Equals(listEntities.Value.First()));
        }