public void Should_ThrowException_When_InvalidType() { 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("", new Dictionary <string, string>() { ["path"] = "path" }); var specificationScope1 = new SpecificationScope <decimal>(); specificationScopes.Add(30, specificationScope1); var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, false); Action action = () => modelScheme.GetSpecificationScope <TestClass>(30); action.Should().ThrowExactly <InvalidCastException>(); }
public void Should_GetSpecificationScope() { 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("", new Dictionary <string, string>() { ["path"] = "path" }); var modelScheme = new ModelScheme <TestClass>(specificationScopes, rootSpecificationScopeId, errorRegistry, template, pathMap, false); var scope = modelScheme.GetSpecificationScope <TestClass>(10); scope.Should().BeSameAs(rootSpecificationScope); }