Esempio n. 1
0
        public void Mysql_query_provider_get_filter_range_test()
        {
            // Arrange
            var ser      = new JsonObjectSerializer();
            var provider = new MySqlQueryProvider(ser);
            var query    = MessageQuery.Create().WithRange(20, 10);

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

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

            Assert.Equal(expectedResult, result);
        }
Esempio n. 2
0
        public void Mysql_query_provider_get_filter_by_id_test()
        {
            // Arrange
            var guid     = Guid.NewGuid();
            var ser      = new JsonObjectSerializer();
            var provider = new MySqlQueryProvider(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);
        }
Esempio n. 3
0
        public void Mysql_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 MySqlQueryProvider(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);
        }