Пример #1
0
        public void Registration_cannot_have_a_dependency_on_itself()
        {
            var map = new DependencyMap <string>();

            map.Invoking(x => x.Add("one", "1", new[] { "1" }))
            .Should().Throw <ArgumentException>().WithMessage("Item cannot have a dependency on itself.");
        }
Пример #2
0
        public void Adding_duplicate_id_fails()
        {
            var map = new DependencyMap <string>();

            map.Add("one", "1");

            map.Invoking(x => x.Add("two", "1"))
            .Should().Throw <ArgumentException>().WithMessage("Item already added with with ID '1'.");
        }
Пример #3
0
        public void Direct_circular_dependency_is_detected()
        {
            var map = new DependencyMap <string>();

            map.Add("one", "1", new[] { "2" });
            map.Add("two", "2", new[] { "1" });

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            map.Invoking(x => x.Entries.ToList())
            .Should().Throw <ConfigurationException>().WithMessage("Circular dependency with items: 1, 2");
        }
Пример #4
0
        public void Missing_dependency_fails()
        {
            var map = new DependencyMap <string>();

            map.Add("one", "1", new[] { "2" });
            map.Add("two", "2", new[] { "3" });

            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            map.Invoking(x => x.Entries.ToList())
            .Should().Throw <ConfigurationException>().WithMessage("Entry '2' has a dependency on missing entry '3'.");
        }