Beispiel #1
0
        public void ExportInvocation(string dtmi, string expectedDeps, TestHelpers.ClientType clientType)
        {
            string targetRepo = string.Empty;

            if (clientType == TestHelpers.ClientType.Local)
            {
                targetRepo = $"--repo \"{TestHelpers.TestLocalModelRepository}\"";
            }

            (int returnCode, string standardOut, string standardError) =
                ClientInvokator.Invoke($"export --dtmi \"{dtmi}\" {targetRepo}");

            Assert.AreEqual(Handlers.ReturnCodes.Success, returnCode);
            Assert.False(standardError.Contains(Outputs.DefaultErrorToken));

            FileExtractResult extractResult = ParsingUtils.ExtractModels(standardOut);
            List <string>     modelsResult  = extractResult.Models;

            string[] expectedDtmis = $"{dtmi},{expectedDeps}".Split(",", StringSplitOptions.RemoveEmptyEntries);
            Assert.True(modelsResult.Count == expectedDtmis.Length);

            foreach (string model in modelsResult)
            {
                string targetId = ParsingUtils.GetRootId(model);
                Assert.True(expectedDtmis.Contains(targetId));
            }
        }
Beispiel #2
0
        public void ExportOutFile(string dtmi, string outfilePath)
        {
            string qualifiedPath = Path.GetFullPath(outfilePath);

            (int returnCode, _, string standardError) =
                ClientInvokator.Invoke($"export -o \"{qualifiedPath}\" --dtmi \"{dtmi}\" --repo \"{TestHelpers.TestLocalModelRepository}\"");

            Assert.AreEqual(Handlers.ReturnCodes.Success, returnCode);
            Assert.False(standardError.Contains(Outputs.DefaultErrorToken));

            FileExtractResult extractResult = ParsingUtils.ExtractModels(new FileInfo(qualifiedPath));
            List <string>     modelsResult  = extractResult.Models;

            string targetId = ParsingUtils.GetRootId(modelsResult[0]);

            Assert.AreEqual(dtmi, targetId);
        }
Beispiel #3
0
        public void ExportInvocationWithModelFile(string modelFilePath, string expectedDeps)
        {
            string qualifiedModelFilePath = Path.GetFullPath(Path.Combine(TestHelpers.TestLocalModelRepository, modelFilePath));

            (int returnCode, string standardOut, string standardError) =
                ClientInvokator.Invoke($"export --model-file \"{qualifiedModelFilePath}\" --repo \"{TestHelpers.TestLocalModelRepository}\"");

            Assert.AreEqual(Handlers.ReturnCodes.Success, returnCode, standardError);
            Assert.False(standardError.Contains(Outputs.DefaultErrorToken));

            FileExtractResult extractResult = ParsingUtils.ExtractModels(standardOut);
            List <string>     modelsResult  = extractResult.Models;

            string[] expectedDtmis = expectedDeps.Split(",", StringSplitOptions.RemoveEmptyEntries);
            Assert.True(modelsResult.Count == expectedDtmis.Length);

            foreach (string model in modelsResult)
            {
                string targetId = ParsingUtils.GetRootId(model);
                Assert.True(expectedDtmis.Contains(targetId));
            }
        }