public void ShouldAddIndexOnPropertyPathWithInheritance() { /// Arrange var builder = new SchemaIndexingInfoBuilder <Parent>(); /// Act var info = builder .AddIndex(p => ((SpecialChild)p.Child).Speciality) .Build(); /// Assert Assert.Contains(info.Fields.Single(f => f.Id == "child").RelatedSchemaIndexing.Fields, f => f.Id == "speciality"); }
public void ShouldAddIndexOnPropertyPath() { /// Arrange var builder = new SchemaIndexingInfoBuilder <Parent>(); /// Act var info = builder .AddIndex(p => p.Child.FirstName) .Build(); var json = JsonConvert.SerializeObject(info, Formatting.Indented); /// Assert Assert.Contains(info.Fields.Single(f => f.Id == "child").RelatedSchemaIndexing.Fields, f => f.Id == "firstName"); }
public void ShouldAddIndexOnCollectionPathWithInheritance() { /// Arrange var builder = new SchemaIndexingInfoBuilder <Parent>(); /// Act var info = builder .AddIndex(p => p.Children.OfType <SpecialChild>().Select(c => c.Speciality)) .Build(); /// Assert Assert.Contains(info.Fields.Single(f => f.Id == "children").RelatedSchemaIndexing.Fields, f => f.Id == "speciality"); Assert.Null(info.Fields.Single(f => f.Id == "children") .RelatedSchemaIndexing.Fields.Single(f => f.Id == "speciality") .RelatedSchemaIndexing); }
public void ShouldAddMultipleIndexes() { //// Arrange var builder = new SchemaIndexingInfoBuilder <Parent>(); //// Act var info = builder .AddIndex(p => p.Foo) .AddIndex(p => p.Bar) .Build(); var json = JsonConvert.SerializeObject(info, Formatting.Indented); //// Assert Assert.True(info.Fields.Any(f => f.Id == "foo")); Assert.True(info.Fields.Any(f => f.Id == "bar")); Assert.Null(info.Fields.Single(f => f.Id == "foo").RelatedSchemaIndexing); Assert.Null(info.Fields.Single(f => f.Id == "bar").RelatedSchemaIndexing); }
public void ShouldAddIndexOnCollectionPath() { //// Arrange var builder = new SchemaIndexingInfoBuilder <Parent>(); //// Act var info = builder .AddIndex(p => p.Children.Select(c => c.FirstName)) .Build(); var json = JsonConvert.SerializeObject(info, Formatting.Indented); //// Assert Assert.True(info.Fields.Single(f => f.Id == "children") .RelatedSchemaIndexing.Fields.Any(f => f.Id == "firstName")); Assert.Null(info.Fields.Single(f => f.Id == "children") .RelatedSchemaIndexing.Fields.Single(f => f.Id == "firstName") .RelatedSchemaIndexing); }