コード例 #1
0
 public void IncludeXmlCommentsIfExists_NullAssembly_ThrowsArgumentNullException() =>
 Assert.Throws <ArgumentNullException>(() =>
 {
     SwaggerGenOptionsExtensions.IncludeXmlCommentsIfExists(
         new SwaggerGenOptions(),
         (Assembly)null);
 });
コード例 #2
0
 public void IncludeXmlCommentsIfExists_NullOptions_ThrowsArgumentNullException() =>
 Assert.Throws <ArgumentNullException>(() =>
 {
     SwaggerGenOptionsExtensions.IncludeXmlCommentsIfExists(
         null,
         typeof(SwaggerGenOptionsExtensionsTest).GetTypeInfo().Assembly);
 });
        public void IncludeXmlCommentsIfExists_XmlFileExistsWithAssemblyCodeBase_XmlCommentsFileAdded()
        {
            var assembly    = typeof(SwaggerGenOptionsExtensionsTest).GetTypeInfo().Assembly;
            var xmlFilePath = Path.ChangeExtension(new Uri(assembly.CodeBase).AbsolutePath, ".xml");

            File.WriteAllText(xmlFilePath, "<?xml version=\"1.0\"?><doc></doc>");
            var options = new SwaggerGenOptions();

            try
            {
                var actualOptions = SwaggerGenOptionsExtensions.IncludeXmlCommentsIfExists(
                    options,
                    assembly);

                Assert.Same(options, actualOptions);
            }
            finally
            {
                EnsureFileDeleted(xmlFilePath);
            }
        }