2019-04-22 23:07:56 -04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
|
using PoweredSoft.DynamicQuery.Core;
|
2019-10-13 16:34:32 -04:00
|
|
|
|
using PoweredSoft.DynamicQuery.NewtonsoftJson;
|
2019-04-22 23:07:56 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.DynamicQuery.Test
|
|
|
|
|
{
|
|
|
|
|
public class SerializationTests
|
|
|
|
|
{
|
|
|
|
|
[Fact]
|
|
|
|
|
public void QueryCriteria()
|
|
|
|
|
{
|
|
|
|
|
var json = @"{""page"":1,""pageSize"":20,""filters"":[{""type"":""composite"",""filters"":[{""path"":""title"",""value"":""Qui"",""type"":""StartsWith"",""and"":false}]}]}";
|
|
|
|
|
|
|
|
|
|
var serviceCollection = new ServiceCollection();
|
|
|
|
|
serviceCollection.AddPoweredSoftDynamicQuery();
|
|
|
|
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
var settings = new JsonSerializerSettings();
|
2019-10-13 15:06:47 -04:00
|
|
|
|
|
2019-04-22 23:07:56 -04:00
|
|
|
|
settings.Converters.Add(new StringEnumConverter());
|
|
|
|
|
settings.Converters.Add(new DynamicQueryJsonConverter(serviceProvider));
|
|
|
|
|
|
|
|
|
|
var data = JsonConvert.DeserializeObject<IQueryCriteria>(json, settings);
|
|
|
|
|
Assert.NotNull(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|