Esempio n. 1
0
            public void String()
            {
                // Explicit strings are not cached since they are returned directly by the resolver
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Field("name"));
                resolver.CachedFields.Should().Be(0);
            }
Esempio n. 2
0
            public void String()
            {
                // Explicit strings are not cached since they are returned directly by the resolver
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Property("name"));
                resolver.CachedProperties.Should().Be(0);
            }
Esempio n. 3
0
            public void SamePropertyTypesOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Field <FirstTestFieldDocument>(c => c.Project.Name));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <SecondTestFieldDocument>(c => c.Project.Name));
                resolver.CachedFields.Should().Be(2);
            }
Esempio n. 4
0
            public void EquivalentPropertiesOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve((Field)typeof(Person).GetProperty(nameof(Person.Id)));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve((Field)typeof(CommitActivity).GetProperty(nameof(CommitActivity.Id)));
                resolver.CachedFields.Should().Be(2);
            }
Esempio n. 5
0
            public void PropertyInfo()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve((Field)typeof(Project).GetProperty(nameof(Project.Name)));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve((Field)typeof(Project).GetProperty(nameof(Project.Name)));
                resolver.CachedFields.Should().Be(1);
            }
Esempio n. 6
0
            public void EquivalentExpressionsOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Field <CommitActivity>(c => c.Id));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <Person>(p => p.Id));
                resolver.CachedFields.Should().Be(2);
            }
Esempio n. 7
0
            public void SamePropertyTypesWithDifferentNames()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Property <TestFieldDocument>(c => c.ProjectA));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve(Property <TestFieldDocument>(c => c.ProjectB));
                resolver.CachedProperties.Should().Be(2);
            }
Esempio n. 8
0
            public void SamePropertyTypesWithDifferentNames()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Field <TestFieldDocument>(c => c.ProjectA));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <TestFieldDocument>(c => c.ProjectB));
                resolver.CachedFields.Should().Be(2);
            }
Esempio n. 9
0
            public void ExpressionWithDifferentParameter()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Property <Project>(p => p.Name));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve(Property <Project>(d => d.Name));
                resolver.CachedProperties.Should().Be(1);
            }
Esempio n. 10
0
            public void Expression()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Property <Project>(p => p.Name));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve(Property <Project>(p => p.Name));
                resolver.CachedProperties.Should().Be(1);
            }
Esempio n. 11
0
            public void PropertyInfo()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve((PropertyName)typeof(Project).GetProperty(nameof(Project.Name)));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve((PropertyName)typeof(Project).GetProperty(nameof(Project.Name)));
                resolver.CachedProperties.Should().Be(1);
            }
Esempio n. 12
0
            public void EquivalentExpressionsOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Property <CommitActivity>(c => c.Id));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve(Property <Person>(c => c.Id));
                resolver.CachedProperties.Should().Be(2);
            }
Esempio n. 13
0
            public void EquivalentPropertiesOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve((PropertyName)typeof(Person).GetProperty(nameof(Person.Id)));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve((PropertyName)typeof(CommitActivity).GetProperty(nameof(CommitActivity.Id)));
                resolver.CachedProperties.Should().Be(2);
            }
Esempio n. 14
0
            public void SamePropertyTypesOnDifferentTypes()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Property <FirstTestFieldDocument>(c => c.Project.Name));
                resolver.CachedProperties.Should().Be(1);
                resolver.Resolve(Property <SecondTestFieldDocument>(c => c.Project.Name));
                resolver.CachedProperties.Should().Be(2);
            }
Esempio n. 15
0
            public void ExpressionWithDictionaryItemConstantExpressionAndConstantSuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key1"].Suffix("x")));

                resolver.CachedFields.Should().Be(1);
                resolved.Should().Be("metadata.key1.x");
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key2"].Suffix("y")));
                resolver.CachedFields.Should().Be(2);
                resolved.Should().Be("metadata.key2.y");
            }
            public void ExpressionWithDictionaryItemConstantExpression()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key1"]));

                resolver.CachedFields.Should().Be(1);
                resolved.Should().Contain("key1");
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key2"]));
                resolver.CachedFields.Should().Be(2);
                resolved.Should().Contain("key2");
            }
Esempio n. 17
0
            public void ExpressionWithDictionaryItemConstantExpression()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key1"]));

                resolver.CachedFields.Should().Be(1);
                resolved.Should().Be("metadata.key1");
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key2"]));
                resolver.CachedFields.Should().Be(2);
                resolved.Should().Be("metadata.key2");
            }
Esempio n. 18
0
            public void ExpressionWithConstantSuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix("raw")));

                resolver.CachedFields.Should().Be(1);
                resolved.Should().EndWith("raw");
                resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix("foo")));
                resolver.CachedFields.Should().Be(2);
                resolved.Should().EndWith("foo");
            }
Esempio n. 19
0
            public void Expression()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Field <Project>(p => p.Name));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <Project>(p => p.Name));
                resolver.CachedFields.Should().Be(1);
                // Boost values should have no bearing on cached field names
                resolver.Resolve(Field <Project>(p => p.Name, 1.1));
                resolver.CachedFields.Should().Be(1);
            }
Esempio n. 20
0
            public void ExpressionWithDifferentParameters()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());

                resolver.Resolve(Field <Project>(p => p.Name));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <Project>(d => d.Name));
                resolver.CachedFields.Should().Be(1);
                // Boost values should have no bearing on cached field names
                resolver.Resolve(Field <Project>(e => e.Name, 1.1));
                resolver.CachedFields.Should().Be(1);
            }
Esempio n. 21
0
            public void ExpressionWithDictionaryItemVariableExpression()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var key      = "key1";
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata[key]));

                resolver.CachedFields.Should().Be(0);
                resolved.Should().Contain(key);
                key      = "key2";
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata[key]));
                resolver.CachedFields.Should().Be(0);
                resolved.Should().Contain(key);
            }
            public void ExpressionWithDictionaryItemConstantExpressionAndVariableSuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var suffix   = "x";
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key1"].Suffix(suffix)));

                resolver.CachedFields.Should().Be(0);
                resolved.Should().Contain("key1").And.EndWith(".x");
                suffix   = "y";
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key2"].Suffix(suffix)));
                resolver.CachedFields.Should().Be(0);
                resolved.Should().Contain("key2").And.EndWith(".y");
            }
Esempio n. 23
0
            public void ExpressionWithVariableSuffix()
            {
                var suffix   = "raw";
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix(suffix)));

                resolved.Should().Be("name.raw");
                resolver.CachedFields.Should().Be(0);
                suffix   = "foo";
                resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix(suffix)));
                resolved.Should().Be("name.foo");
                resolver.CachedFields.Should().Be(0);
            }
Esempio n. 24
0
            public void ExpressionWithDictionaryItemConstantExpressionAndVariableSuffix()
            {
                var resolver = new TestableFieldResolver(new ElasticsearchClientSettings());
                var suffix   = "x";
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key1"].Suffix(suffix)));

                resolver.CachedFields.Should().Be(0);
                resolved.Should().Be("metadata.key1.x");
                suffix   = "y";
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata["key2"].Suffix(suffix)));
                resolver.CachedFields.Should().Be(0);
                resolved.Should().Be("metadata.key2.y");
            }
Esempio n. 25
0
            public void ExpressionWithSuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());

                resolver.Resolve(Field <Project>(p => p.Name));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <Project>(p => p.Name));
                resolver.CachedFields.Should().Be(1);
                resolver.Resolve(Field <Project>(p => p.Name.Suffix("raw")));
                resolver.CachedFields.Should().Be(2);
                resolver.Resolve(Field <Project>(p => p.Name.Suffix("raw"), 1.1));
                resolver.CachedFields.Should().Be(2);
            }
Esempio n. 26
0
            public void ExpressionWithDictionaryItemVariableExpressionAndEquivalentConstantSuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var key      = "key1";
                var resolved = resolver.Resolve(Field <Project>(p => p.Metadata[key].Suffix("x")));

                resolver.CachedFields.Should().Be(0);
                resolved.Should().Be($"metadata.{key}.x");
                key      = "key2";
                resolved = resolver.Resolve(Field <Project>(p => p.Metadata[key].Suffix("x")));
                resolver.CachedFields.Should().Be(0);
                resolved.Should().Be($"metadata.{key}.x");
            }
Esempio n. 27
0
            public void ExpressionWithDictionarySuffix()
            {
                var resolver = new TestableFieldResolver(new ConnectionSettings());
                var key      = "key1";
                var d        = new Dictionary <string, string> {
                    { "key1", "raw" }, { "key2", "foo" }
                };
                var resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix(d[key])));

                resolved.Should().EndWith("raw");
                resolver.CachedFields.Should().Be(0);
                resolver.Resolve(Field <Project>(p => p.Name.Suffix(d["key1"])));
                resolver.CachedFields.Should().Be(0);

                key      = "key2";
                resolved = resolver.Resolve(Field <Project>(p => p.Name.Suffix(d[key])));
                resolved.Should().EndWith("foo");
                resolver.CachedFields.Should().Be(0);
                resolver.Resolve(Field <Project>(p => p.Name.Suffix(d["key2"])));
                resolver.CachedFields.Should().Be(0);
            }
			public void ExpressionWithConstantSuffix()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix("raw")));
				resolver.CachedFields.Should().Be(1);
				resolved.Should().EndWith("raw");
				resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix("foo")));
				resolver.CachedFields.Should().Be(2);
				resolved.Should().EndWith("foo");
			}
			public void ExpressionWithVariableSuffix()
			{
				var suffix = "raw";
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix(suffix)));
				resolved.Should().Be("name.raw");
				resolver.CachedFields.Should().Be(0);
				suffix = "foo";
				resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix(suffix)));
				resolved.Should().Be("name.foo");
				resolver.CachedFields.Should().Be(0);
			}
			public void ExpressionWithDictionaryItemVariableExpression()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var key = "key1";
				var resolved = resolver.Resolve(Field<Project>(p => p.Metadata[key]));
				resolver.CachedFields.Should().Be(0);
				resolved.Should().Contain(key);
				key = "key2";
				resolved = resolver.Resolve(Field<Project>(p => p.Metadata[key]));
				resolver.CachedFields.Should().Be(0);
				resolved.Should().Contain(key);
			}
			public void ExpressionWithDictionaryItemVariableExpressionAndEquivalentConstantSuffix()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var key = "key1";
				var resolved = resolver.Resolve(Field<Project>(p => p.Metadata[key].Suffix("x")));
				resolver.CachedFields.Should().Be(0);
				resolved.Should().Be($"metadata.{key}.x");
				key = "key2";
				resolved = resolver.Resolve(Field<Project>(p => p.Metadata[key].Suffix("x")));
				resolver.CachedFields.Should().Be(0);
				resolved.Should().Be($"metadata.{key}.x");
			}
			public void ExpressionWithDictionaryItemConstantExpressionAndConstantSuffix()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var resolved = resolver.Resolve(Field<Project>(p => p.Metadata["key1"].Suffix("x")));
				resolver.CachedFields.Should().Be(1);
				resolved.Should().Be("metadata.key1.x");
				resolved = resolver.Resolve(Field<Project>(p => p.Metadata["key2"].Suffix("y")));
				resolver.CachedFields.Should().Be(2);
				resolved.Should().Be("metadata.key2.y");
			}
			public void EquivalentPropertiesOnDifferentTypes()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve((PropertyName)typeof(Person).GetProperty(nameof(Person.Id)));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve((PropertyName)typeof(CommitActivity).GetProperty(nameof(CommitActivity.Id)));
				resolver.CachedProperties.Should().Be(2);
			}
			public void ExpressionWithDictionarySuffix()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				var key = "key1";
				var d = new Dictionary<string, string> { { "key1", "raw" }, { "key2", "foo" } };
				var resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix(d[key])));
				resolved.Should().EndWith("raw");
				resolver.CachedFields.Should().Be(0);
				resolver.Resolve(Field<Project>(p => p.Name.Suffix(d["key1"])));
				resolver.CachedFields.Should().Be(0);

				key = "key2";
				resolved = resolver.Resolve(Field<Project>(p => p.Name.Suffix(d[key])));
				resolved.Should().EndWith("foo");
				resolver.CachedFields.Should().Be(0);
				resolver.Resolve(Field<Project>(p => p.Name.Suffix(d["key2"])));
				resolver.CachedFields.Should().Be(0);
			}
			public void Expression()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Field<Project>(p => p.Name));
				resolver.CachedFields.Should().Be(1);
				resolver.Resolve(Field<Project>(p => p.Name));
				resolver.CachedFields.Should().Be(1);
				// Boost values should have no bearing on cached field names
				resolver.Resolve(Field<Project>(p => p.Name, 1.1));
				resolver.CachedFields.Should().Be(1);
			}
			public void SamePropertyTypesWithDifferentNames()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Property<TestFieldDocument>(c => c.ProjectA));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve(Property<TestFieldDocument>(c => c.ProjectB));
				resolver.CachedProperties.Should().Be(2);
			}
			public void SamePropertyTypesOnDifferentTypes()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Property<FirstTestFieldDocument>(c => c.Project.Name));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve(Property<SecondTestFieldDocument>(c => c.Project.Name));
				resolver.CachedProperties.Should().Be(2);
			}
			public void ExpressionWithSuffix()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Field<Project>(p => p.Name));
				resolver.CachedFields.Should().Be(1);
				resolver.Resolve(Field<Project>(p => p.Name));
				resolver.CachedFields.Should().Be(1);
				resolver.Resolve(Field<Project>(p => p.Name.Suffix("raw")));
				resolver.CachedFields.Should().Be(2);
				resolver.Resolve(Field<Project>(p => p.Name.Suffix("raw"), 1.1));
				resolver.CachedFields.Should().Be(2);
			}
			public void ExpressionWithDifferentParameter()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Property<Project>(p => p.Name));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve(Property<Project>(d => d.Name));
				resolver.CachedProperties.Should().Be(1);
			}
			public void PropertyInfo()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve((PropertyName)typeof(Project).GetProperty(nameof(Project.Name)));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve((PropertyName)typeof(Project).GetProperty(nameof(Project.Name)));
				resolver.CachedProperties.Should().Be(1);
			}
			public void String()
			{
				// Explicit strings are not cached since they are returned directly by the resolver
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Property("name"));
				resolver.CachedProperties.Should().Be(0);
			}
			public void EquivalentExpressionsOnDifferentTypes()
			{
				var resolver = new TestableFieldResolver(new ConnectionSettings());
				resolver.Resolve(Property<CommitActivity>(c => c.Id));
				resolver.CachedProperties.Should().Be(1);
				resolver.Resolve(Property<Person>(c => c.Id));
				resolver.CachedProperties.Should().Be(2);
			}