Пример #1
0
        public void IndexConfigTest()
        {
            var x = new IndexOptions();

            Console.WriteLine(x.ToString());

            x.Name = "name";
            Assert.That(x.Name, Is.EqualTo("name"));

            Assert.That(x.Type, Is.EqualTo(IndexOptions.DefaultType));
            x.Type = IndexType.Hashed;
            Assert.That(x.Type, Is.EqualTo(IndexType.Hashed));

            x = new IndexOptions(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));

            IndexOptions.ValidateAttribute(x, "flub");

            Assert.Throws <ArgumentNullException>(() => IndexOptions.ValidateAttribute(x, null));
            Assert.Throws <ArgumentException>(() => IndexOptions.ValidateAttribute(x, ""));
            Assert.Throws <ArgumentException>(() => IndexOptions.ValidateAttribute(x, "duh."));
        }