public void IndexConfigTest() { var x = new IndexConfig(); Console.WriteLine(x.ToString()); x.Name = "name"; Assert.That(x.Name, Is.EqualTo("name")); Assert.That(x.Type, Is.EqualTo(IndexConfig.DefaultType)); x.Type = IndexType.Hashed; Assert.That(x.Type, Is.EqualTo(IndexType.Hashed)); x = new IndexConfig(new [] { "aaa", "bbb" }); Assert.That(x.Attributes.Count, Is.EqualTo(2)); x.AddAttribute("ccc"); Assert.That(x.Attributes.Count, Is.EqualTo(3)); Assert.That(x.Attributes, Does.Contain("aaa")); Assert.That(x.Attributes, Does.Contain("bbb")); Assert.That(x.Attributes, Does.Contain("ccc")); Assert.That(x.BitmapIndexOptions, Is.Not.Null); var y = new BitmapIndexOptions(); x.BitmapIndexOptions = y; Assert.That(x.BitmapIndexOptions, Is.SameAs(y)); IndexConfig.ValidateAttribute(x, "flub"); Assert.Throws <ArgumentNullException>(() => IndexConfig.ValidateAttribute(x, null)); Assert.Throws <ArgumentException>(() => IndexConfig.ValidateAttribute(x, "")); Assert.Throws <ArgumentException>(() => IndexConfig.ValidateAttribute(x, "duh.")); }
private static IndexConfig BuildNormalizedConfig(string mapName, IndexType indexType, string indexName, List <string> normalizedAttributeNames) { var newConfig = new IndexConfig { Type = indexType }; var nameBuilder = indexName == null ? new StringBuilder(mapName + "_" + GetIndexTypeName(indexType)) : null; foreach (var normalizedAttributeName in normalizedAttributeNames) { newConfig.AddAttribute(normalizedAttributeName); nameBuilder?.Append("_").Append(normalizedAttributeName); } if (nameBuilder != null) { indexName = nameBuilder.ToString(); } { } newConfig.Name = indexName; return(newConfig); }