예제 #1
0
            public void Should_ReturnPathFromFromPathsHelper_IfOnlyNextLevelNotPresent()
            {
                var rootSpecificationScope   = new SpecificationScope <TestClass>();
                var rootSpecificationScopeId = 10;
                var specificationScopes      = new Dictionary <int, object>();

                specificationScopes.Add(rootSpecificationScopeId, rootSpecificationScope);
                var errorRegistry = new Dictionary <int, IError>();

                errorRegistry.Add(44, new Error());
                var template = new Dictionary <string, IReadOnlyList <int> >();

                template.Add("path", new[] { 44 });

                var pathMap = new Dictionary <string, IReadOnlyDictionary <string, string> >();

                pathMap.Add("first", new Dictionary <string, string>()
                {
                    ["next_level_not_present"] = "third"
                });

                var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, Substitute.For <ICapacityInfo>(), false);

                var path = modelScheme.ResolvePath("first", "second");

                path.Should().Be("first.second");
            }
예제 #2
0
            public void Should_ReturnPathFromMap_IfPresent()
            {
                var rootSpecificationScope   = new SpecificationScope <TestClass>();
                var rootSpecificationScopeId = 10;
                var specificationScopes      = new Dictionary <int, object>();

                specificationScopes.Add(rootSpecificationScopeId, rootSpecificationScope);
                var errorRegistry = new Dictionary <int, IError>();

                errorRegistry.Add(44, new Error());
                var template = new Dictionary <string, IReadOnlyList <int> >();

                template.Add("path", new[] { 44 });

                var pathMap = new Dictionary <string, IReadOnlyDictionary <string, string> >();

                pathMap.Add("first", new Dictionary <string, string>()
                {
                    ["second"] = "third"
                });

                var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, false);

                var path = modelScheme.ResolvePath("first", "second");

                path.Should().Be("third");
            }
예제 #3
0
            public void Should_ReturnPath_FroMapIfAllPresent_FromHelperIfNot()
            {
                var rootSpecificationScope   = new SpecificationScope <TestClass>();
                var rootSpecificationScopeId = 10;
                var specificationScopes      = new Dictionary <int, object>();

                specificationScopes.Add(rootSpecificationScopeId, rootSpecificationScope);
                var errorRegistry = new Dictionary <int, IError>();

                errorRegistry.Add(44, new Error());
                var template = new Dictionary <string, IReadOnlyList <int> >();

                template.Add("path", new[] { 44 });

                var pathMap = new Dictionary <string, IReadOnlyDictionary <string, string> >();

                pathMap.Add("A", new Dictionary <string, string>()
                {
                    ["B"]  = "C",
                    ["b"]  = "c",
                    ["d"]  = "d",
                    ["b2"] = "c2",
                    ["<X"] = "XPATH",
                });

                var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, Substitute.For <ICapacityInfo>(), false);

                modelScheme.ResolvePath("first", "second").Should().Be("first.second");
                modelScheme.ResolvePath("A", "B").Should().Be("C");
                modelScheme.ResolvePath("a", "B").Should().Be("a.B");
                modelScheme.ResolvePath("A", "B1").Should().Be("A.B1");
                modelScheme.ResolvePath("A", "b").Should().Be("c");
                modelScheme.ResolvePath("A", "d").Should().Be("d");

                modelScheme.ResolvePath("A", "<X").Should().Be("XPATH");
                modelScheme.ResolvePath("A", "<x").Should().Be("x");
            }
예제 #4
0
            public void Should_ReturnPathFromHelper_IfNotPresent(string basePath, string newSegment, string expectedPath)
            {
                var rootSpecificationScope   = new SpecificationScope <TestClass>();
                var rootSpecificationScopeId = 10;
                var specificationScopes      = new Dictionary <int, object>();

                specificationScopes.Add(rootSpecificationScopeId, rootSpecificationScope);
                var errorRegistry = new Dictionary <int, IError>();

                errorRegistry.Add(44, new Error());
                var template = new Dictionary <string, IReadOnlyList <int> >();

                template.Add("path", new[] { 44 });

                var pathMap = new Dictionary <string, IReadOnlyDictionary <string, string> >();

                var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, Substitute.For <ICapacityInfo>(), false);

                var path = modelScheme.ResolvePath(basePath, newSegment);

                path.Should().Be(expectedPath);
            }