public void GenerateSimpleServiceYaml()
        {
            var generator = new SwaggerGenerator {
                GeneratesJson = false, GeneratorName = "tests"
            };
            var fsdService = TestUtility.ParseTestApi(c_fsdText);
            var file       = generator.GenerateOutput(fsdService).Files.Single();

            file.Name.Should().Be("TestApi.yaml");
            var jToken         = JToken.FromObject(new DeserializerBuilder().Build().Deserialize(new StringReader(file.Text)));
            var jTokenExpected = JToken.FromObject(s_swaggerService, JsonSerializer.Create(SwaggerUtility.JsonSerializerSettings));

            JToken.DeepEquals(jToken, jTokenExpected).Should().BeTrue("{0} should be {1}", jToken, jTokenExpected);

            var service = new SwaggerParser().ParseDefinition(new ServiceDefinitionText(name: file.Name, text: file.Text));

            service.Summary.Should().Be("TestApi");
            service.Methods.Count.Should().Be(fsdService.Methods.Count);
        }
        public void GenerateSimpleServiceYaml()
        {
            var generator = new SwaggerGenerator {
                Yaml = true, GeneratorName = "tests"
            };
            var fsdService = TestUtility.ParseTestApi(s_fsdText);
            var namedText  = generator.GenerateOutput(fsdService).NamedTexts.Single();

            namedText.Name.ShouldBe("TestApi.yaml");
            var jToken         = JToken.FromObject(new YamlDotNet.Serialization.DeserializerBuilder().Build().Deserialize(new StringReader(namedText.Text)));
            var jTokenExpected = JToken.FromObject(s_swaggerService, JsonSerializer.Create(SwaggerUtility.JsonSerializerSettings));

            JToken.DeepEquals(jToken, jTokenExpected).ShouldBe(true);

            var service = new SwaggerParser().ParseDefinition(namedText);

            service.Summary.ShouldBe("TestApi");
            service.Methods.Count.ShouldBe(fsdService.Methods.Count);
        }
        public void GenerateComplexService()
        {
            var generator = new SwaggerGenerator {
                GeneratorName = "tests"
            };
            var fsdService = TestUtility.ParseTestApi(s_fsdText);
            var output     = generator.GenerateOutput(fsdService);
            var namedText  = output.NamedTexts.Single();

            namedText.Name.ShouldBe("TestApi.json");
            var jToken         = JToken.Parse(namedText.Text);
            var jTokenExpected = JToken.FromObject(s_swaggerService, JsonSerializer.Create(SwaggerUtility.JsonSerializerSettings));

            JToken.DeepEquals(jToken, jTokenExpected).ShouldBe(true);

            var service = new SwaggerParser().ParseDefinition(namedText);

            service.Summary.ShouldBe(fsdService.Summary);
            service.Methods.Count.ShouldBe(fsdService.Methods.Count);
        }
        public void GenerateComplexService()
        {
            var generator = new SwaggerGenerator {
                GeneratesJson = true, GeneratorName = "tests"
            };
            var fsdService = TestUtility.ParseTestApi(c_fsdText);
            var output     = generator.GenerateOutput(fsdService);
            var file       = output.Files.Single();

            file.Name.Should().Be("TestApi.json");
            var jToken         = JToken.Parse(file.Text);
            var jTokenExpected = JToken.FromObject(s_swaggerService, JsonSerializer.Create(SwaggerUtility.JsonSerializerSettings));

            if (!JToken.DeepEquals(jToken, jTokenExpected))
            {
                jToken.ToString(Formatting.None).Should().Be(jTokenExpected.ToString(Formatting.None));
            }

            var service = new SwaggerParser().ParseDefinition(new ServiceDefinitionText(name: file.Name, text: file.Text));

            service.Summary.Should().Be(fsdService.Summary);
            service.Methods.Count.Should().Be(fsdService.Methods.Count);
        }