public void UsesTheFunctionPassedInToDetermineTheKeyOfAnObject()
        {
            var item = new Foo {Bar = "a", Baz = "z"};
            var collection = new FunctionalKeyedCollection<string, Foo>(foo => foo.Bar) { item };

            Assert.That(collection["a"], Is.SameAs(item));
            Assert.That(() => collection["z"], Throws.Exception);
        }
Exemplo n.º 2
0
        public void UsesTheFunctionPassedInToDetermineTheKeyOfAnObject()
        {
            var item = new Foo {
                Bar = "a", Baz = "z"
            };
            var collection = new FunctionalKeyedCollection <string, Foo>(foo => foo.Bar)
            {
                item
            };

            Assert.That(collection["a"], Is.SameAs(item));
            Assert.That(() => collection["z"], Throws.Exception);
        }