Ejemplo n.º 1
0
        public void Sqlite_query_provider_get_filter_range_test()
        {
            // Arrange
            var ser      = new JsonObjectSerializer();
            var provider = new SqliteQueryProvider(ser);
            var query    = MessageQuery.Create().WithRange(20, 10);

            // Act
            var result = provider.GetFilterScript(query);

            // Assert
            var expectedResult =
                $@"SELECT * FROM saritasa_messages
LIMIT 10 OFFSET 20";

            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 2
0
        public void Sqlite_query_provider_get_filter_by_id_test()
        {
            // Arrange
            var guid     = Guid.NewGuid();
            var ser      = new JsonObjectSerializer();
            var provider = new SqliteQueryProvider(ser);
            var query    = MessageQuery.Create().WithId(guid);

            // Act
            var result = provider.GetFilterScript(query);

            // Assert
            var expectedResult =
                $@"SELECT * FROM saritasa_messages
WHERE (content_id = '{guid}')
LIMIT 1000";

            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 3
0
        public void Sqlite_query_provider_get_filter_by_date_test()
        {
            // Arrange
            var startDate = new DateTime(2016, 1, 1);
            var endDate   = new DateTime(2016, 12, 31, 23, 0, 0);
            var ser       = new JsonObjectSerializer();
            var provider  = new SqliteQueryProvider(ser);
            var query     = MessageQuery.Create()
                            .WithCreatedStartDate(startDate)
                            .WithCreatedEndDate(endDate);

            // Act
            var result = provider.GetFilterScript(query);

            // Assert
            var expectedResult =
                $@"SELECT * FROM saritasa_messages
WHERE (created_at >= '{startDate:yyyy-MM-dd hh:mm:ss}') AND (created_at <= '{endDate:yyyy-MM-dd hh:mm:ss}')
LIMIT 1000";

            Assert.Equal(expectedResult, result);
        }