public void Serialize_EqualAndNotEqual_ShouldHaveCorrectPath()
 {
     NestSerializer
     .Serialize <TestData>(data => data.StringProperty == "Test" && data.LongProperty != 42)
     .Should()
     .BeValidJson()
     .And
     .ContainInOrder("query", "bool", "must", "bool", "must", "term", "StringProperty", "Test", "must_not", "term", "LongProperty", "42");
 }
 public void Serialize_Equal_ShouldHaveCorrectPath()
 {
     NestSerializer
     .Serialize <TestData>(data => data.StringProperty == "Test")
     .Should()
     .BeValidJson()
     .And
     .ContainInOrder("term", "StringProperty", "Test");
 }
 public void Serialize_GetInnerProperty_ShouldHaveCorrectPath()
 {
     NestSerializer
     .Serialize <TestData>(data => data.Inner.Inner.BoolProperty)
     .Should()
     .BeValidJson()
     .And
     .ContainInOrder("term", "Inner.Inner.BoolProperty");
 }
 public void Serialize_GetBoolProperty_ShouldHaveCorrectPath()
 {
     NestSerializer
     .Serialize <TestData>(data => data.BoolProperty)
     .Should()
     .BeValidJson()
     .And
     .ContainInOrder("query", "bool", "must", "term", "BoolProperty");
 }
		public static IElasticClient GetFixedReturnClient(object responseJson)
		{
			var serializer = new NestSerializer(new ConnectionSettings());
			byte[] fixedResult;
			using (var ms = new MemoryStream())
			{
				serializer.Serialize(responseJson, ms);
				fixedResult = ms.ToArray();
			}
			var connection = new InMemoryConnection(fixedResult);
			var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
			var settings = new ConnectionSettings(connectionPool, connection);
			return new ElasticClient(settings);
		}
        public void SerializationTest()
        {
            const string Test = nameof(Test);
            Expression <Func <TestData, bool> > exp = data => data.StringProperty == "Test" && data.LongProperty == 42;

            var result = NestSerializer.Serialize(exp);

            //Console.Out.WriteLine(NestSerializer.Probe(exp));
            //Console.Out.WriteLine("==Result==");
            Console.Out.WriteLine(result);

            result
            .Should()
            .NotBeNullOrEmpty();
        }
        public static IElasticClient GetFixedReturnClient(object responseJson)
        {
            var serializer = new NestSerializer(new ConnectionSettings());

            byte[] fixedResult;
            using (var ms = new MemoryStream())
            {
                serializer.Serialize(responseJson, ms);
                fixedResult = ms.ToArray();
            }
            var connection     = new InMemoryConnection(fixedResult);
            var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
            var settings       = new ConnectionSettings(connectionPool, connection);

            return(new ElasticClient(settings));
        }