public void GetLayersNamespaces_RegExGrouped_Error_NamespaceNotFoundForLayer() { var key = "Origin"; var layers = new Dictionary <string, NamespacesGroupingMethod>() { { key, new NamespacesRegularExpressionGrouped() } }; var result = Assert.Throws <ConstraintsException>(() => { _ = NamespacesGroupingMethodHelper.GetLayersNamespaces( layers, new List <string>()); }); Assert.Equal(ConstraintsError.NamespaceNotFoundForLayer(key).Key, result.Key); }
private static void ChecksExplicitlyEmptyLayers( ArchitecturalConstraints constraints) { var explicitlyDefinedLayers = constraints.Layers .Where(l => l.Value is NamespacesExplicitlyGrouped) .Select(l => new KeyValuePair <string, NamespacesExplicitlyGrouped>( l.Key, (NamespacesExplicitlyGrouped)l.Value)); if (explicitlyDefinedLayers.Any()) { foreach (var layer in explicitlyDefinedLayers) { if (layer.Value.Namespaces == null || !layer.Value.Namespaces.Any()) { throw new ConstraintsException( ConstraintsError.NamespaceNotFoundForLayer(layer.Key)); } } } }
public static IDictionary <string, IEnumerable <string> > GetLayersNamespaces( IDictionary <string, NamespacesGroupingMethod> layers, IEnumerable <string> namespaces) { var layersNamespaces = new Dictionary <string, IEnumerable <string> >(); foreach (var layer in layers) { if (!layersNamespaces.ContainsKey(layer.Key)) { var layerNamespaces = GetNamespaces( layer.Value, namespaces); if (layerNamespaces == null || !layerNamespaces.Any()) { throw new ConstraintsException( ConstraintsError.NamespaceNotFoundForLayer(layer.Key)); } layersNamespaces.Add(layer.Key, layerNamespaces); } } return(layersNamespaces); }