Пример #1
0
        public void FunctionsShouldHaveExpectedSignatures(INamespaceSymbol @namespace)
        {
            var knownOverloads = @namespace.TryGetNamespaceType() !.MethodResolver.GetKnownFunctions().Values
                                 .SelectMany(function => function.Overloads)
                                 .OrderBy(overload => overload.Name)
                                 .Select(Convert);

            var actual         = JToken.FromObject(knownOverloads, DataSetSerialization.CreateSerializer());
            var actualLocation = FileHelper.SaveResultFile(this.TestContext, $"{this.TestContext.TestName}_{@namespace.Name}.json", actual.ToString(Formatting.Indented));

            var fileName = $"{@namespace.Name}.json";

            var expectedStr = DataSets.Functions.TryGetValue(fileName);

            if (expectedStr == null)
            {
                throw new AssertFailedException($"The function baseline file for namespace '{@namespace.Name}' does not exist.");
            }

            var expected     = JToken.Parse(expectedStr);
            var expectedPath = Path.Combine("src", "Bicep.Core.Samples", "Files", DataSet.TestFunctionsDirectory, fileName);

            actual.Should().EqualWithJsonDiffOutput(TestContext, expected, expectedPath, actualLocation);
        }