public void IdentifyDuplicatePaths()
        {
            // these swagger operations have more than 1 version of it. ( usually because they come from different providers)
            // client will pick the last swagger definition it sees and use that.
            var knownDuplicates = new HashSet <string>();

            knownDuplicates.Add(
                "https://management.azure.com/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/operations");
            knownDuplicates.Add(
                "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources");

            var root             = new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent.Parent;
            var fileRelative     = Path.Combine("App_Data", "SwaggerSpecs");
            var swaggerDirectory = Path.Combine(root.FullName, fileRelative);
            var metadataObjects  = new List <MetadataObject>();

            foreach (var directory in Directory.GetDirectories(swaggerDirectory))
            {
                foreach (var swaggerFile in Directory.GetFiles(directory))
                {
                    var serviceDefinition = SwaggerParser.Load(swaggerFile, new FileSystem());
                    var builder           = new MetaDataObjectBuilder(serviceDefinition);
                    metadataObjects.AddRange(builder.GetMetaDataObjects());
                }
            }

            Assert.NotEmpty(metadataObjects);
            var speclessMetadataObjects = HyakUtils.GetSpeclessCsmOperations().ToList();

            Assert.NotEmpty(speclessMetadataObjects);
            metadataObjects.AddRange(speclessMetadataObjects);

            var operationsCount = new Dictionary <UniqueOperation, HashSet <string> >();

            foreach (var metadataObject in metadataObjects)
            {
                var uniqueOperation = new UniqueOperation(metadataObject.Url, metadataObject.HttpMethod);
                if (!operationsCount.ContainsKey(uniqueOperation))
                {
                    operationsCount[uniqueOperation] = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                }
                operationsCount[uniqueOperation].Add(metadataObject.ApiVersion);
            }
            foreach (var oCount in operationsCount)
            {
                if (oCount.Value.Count > 1)
                {
                    Assert.True(knownDuplicates.Contains(oCount.Key.Url));
                }
            }
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var _prototype1 = new ReplaceOperation()
            {
                Args = new ReplaceArgs()
                {
                    From = "origin string",
                    To   = "new string"
                }
            };

            _prototype.Add(_prototype1);
            prototypeMethodCobobox.ItemsSource = _prototype;
            operationListBox.ItemsSource       = _action;

            var _prototype2 = new ISBNOperation()
            {
                Args = new ISBNArgs()
                {
                    Direction = "before"
                }
            };

            _prototype.Add(_prototype2);
            prototypeMethodCobobox.ItemsSource = _prototype;
            operationListBox.ItemsSource       = _action;

            var _prototype3 = new UniqueOperation()
            {
            };

            _prototype.Add(_prototype3);
            prototypeMethodCobobox.ItemsSource = _prototype;
            operationListBox.ItemsSource       = _action;


            // ADD file
            fileView.ItemsSource = _fileName;
            // ADD folder
            folderView.ItemsSource = _folderName;

            presetComboBox.ItemsSource = _preset;
        }