Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some unit tests for c# and the publiconly flag. #259

Merged
merged 3 commits into from
Feb 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions FSharp.Formatting.Tests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crefLib3", "tests\FSharp.Me
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "crefLib4", "tests\FSharp.MetadataFormat.Tests\files\crefLib\crefLib4.csproj", "{98624699-1B2F-4636-A3F7-EC72343CB2FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "csharpSupport", "tests\FSharp.MetadataFormat.Tests\files\csharpSupport\csharpSupport.csproj", "{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -139,6 +141,16 @@ Global
{98624699-1B2F-4636-A3F7-EC72343CB2FD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{98624699-1B2F-4636-A3F7-EC72343CB2FD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{98624699-1B2F-4636-A3F7-EC72343CB2FD}.Release|x86.ActiveCfg = Release|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Debug|x86.ActiveCfg = Debug|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|Any CPU.Build.0 = Release|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -150,5 +162,6 @@ Global
{55728B9D-1EDE-4A40-B439-1EB0B3F77B72} = {0BCA32CA-96E2-4E6A-9697-681E2131F40A}
{08029B28-A5EA-42DB-AB4E-9C6BA9EF9441} = {0BCA32CA-96E2-4E6A-9697-681E2131F40A}
{98624699-1B2F-4636-A3F7-EC72343CB2FD} = {0BCA32CA-96E2-4E6A-9697-681E2131F40A}
{DA7BA2FA-447E-41F3-88D9-00CF3E052E2C} = {0BCA32CA-96E2-4E6A-9697-681E2131F40A}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Target "Clean" (fun _ ->
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/FsLib/obj"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/crefLib/bin"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/crefLib/obj"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/csharpSupport/bin"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/csharpSupport/obj"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/TestLib/bin"]
CleanDirs ["tests/FSharp.MetadataFormat.Tests/files/TestLib/obj"]
)
Expand Down Expand Up @@ -105,6 +107,12 @@ Target "BuildTests" (fun _ ->
|> MSBuildDebug "" "Rebuild"
|> ignore

{ BaseDirectory = __SOURCE_DIRECTORY__
Includes = ["tests/*/files/csharpSupport/csharpSupport.sln"]
Excludes = [] }
|> MSBuildDebug "" "Rebuild"
|> ignore

{ BaseDirectory = __SOURCE_DIRECTORY__
Includes = ["tests/*/files/TestLib/TestLib.sln"]
Excludes = [] }
Expand Down
4 changes: 2 additions & 2 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ NUGET
remote: http://nuget.org/api/v2
specs:
CommandLineParser (1.9.71)
FAKE (3.14.0)
FSharp.Compiler.Service (0.0.81)
FAKE (3.14.9)
FSharp.Compiler.Service (0.0.82)
Microsoft.AspNet.Razor (2.0.30506.0)
NuGet.CommandLine (2.8.3)
NUnit (2.6.4)
Expand Down
6 changes: 3 additions & 3 deletions src/Common/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("FSharp.Formatting")>]
[<assembly: AssemblyProductAttribute("FSharp.Formatting")>]
[<assembly: AssemblyDescriptionAttribute("A package of libraries for building great F# documentation, samples and blogs")>]
[<assembly: AssemblyVersionAttribute("2.4.38")>]
[<assembly: AssemblyFileVersionAttribute("2.4.38")>]
[<assembly: AssemblyVersionAttribute("2.5.1")>]
[<assembly: AssemblyFileVersionAttribute("2.5.1")>]
[<assembly: AssemblyCopyrightAttribute("Apache 2.0 License")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.4.38"
let [<Literal>] Version = "2.5.1"
106 changes: 106 additions & 0 deletions tests/FSharp.MetadataFormat.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,112 @@ let ``MetadataFormat test that cref generation works``() =
System.Diagnostics.Process.Start(output)
#endif

[<Test>]
let ``MetadataFormat test that csharp (publiconly) support works``() =
let libraries =
[ root @@ "files/csharpSupport/bin/Debug" @@ "csharpSupport.dll" ]
let output = getOutputDir()
printfn "Output: %s" output
MetadataFormat.Generate
( libraries, output, layoutRoots, info, libDirs = [root @@ "../../lib"],
sourceRepo = "https://github.com/tpetricek/FSharp.Formatting/tree/master",
sourceFolder = __SOURCE_DIRECTORY__ @@ "../..",
publicOnly = true,
markDownComments = false )
let fileNames = Directory.GetFiles(output)
let files = dict [ for f in fileNames -> Path.GetFileName(f), File.ReadAllText(f) ]

// C# tests

files.["csharpsupport-sampleclass.html"] |> should contain "My_Sample_Class"

files.["csharpsupport-sampleclass.html"] |> should contain "My_Constructor"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Event"

files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Constructor")
files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Method")
files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Property")
files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Event")

files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Event"


files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Static_Method")
files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Static_Property")
files.["csharpsupport-sampleclass.html"] |> should not' (contain "My_Private_Static_Event")

files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Sample_Class"

files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Method"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Property"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Event"

files.["csharpsupport-samplestaticclass.html"] |> should not' (contain "My_Private_Static_Method")
files.["csharpsupport-samplestaticclass.html"] |> should not' (contain "My_Private_Static_Property")
files.["csharpsupport-samplestaticclass.html"] |> should not' (contain "My_Private_Static_Event")

#if INTERACTIVE
System.Diagnostics.Process.Start(output)
#endif


[<Ignore>]
[<Test>]
let ``MetadataFormat test that csharp support works``() =
let libraries =
[ root @@ "files/csharpSupport/bin/Debug" @@ "csharpSupport.dll" ]
let output = getOutputDir()
printfn "Output: %s" output
MetadataFormat.Generate
( libraries, output, layoutRoots, info, libDirs = [root @@ "../../lib"],
sourceRepo = "https://github.com/tpetricek/FSharp.Formatting/tree/master",
sourceFolder = __SOURCE_DIRECTORY__ @@ "../..",
publicOnly = false,
markDownComments = false )
let fileNames = Directory.GetFiles(output)
let files = dict [ for f in fileNames -> Path.GetFileName(f), File.ReadAllText(f) ]

// C# tests

files.["csharpsupport-sampleclass.html"] |> should contain "My_Sample_Class"

files.["csharpsupport-sampleclass.html"] |> should contain "My_Constructor"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Event"

files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Constructor"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Event"

files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Static_Event"


files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Static_Method"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Static_Property"
files.["csharpsupport-sampleclass.html"] |> should contain "My_Private_Static_Event"

files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Sample_Class"

files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Method"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Property"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Static_Event"

files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Private_Static_Method"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Private_Static_Property"
files.["csharpsupport-samplestaticclass.html"] |> should contain "My_Private_Static_Event"

#if INTERACTIVE
System.Diagnostics.Process.Start(output)
#endif

[<Test>]
let ``MetadataFormat process XML comments in two sample F# assemblies``() =
let libraries =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("csharpSupport")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("csharpSupport")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("476d2809-dd07-4413-b1d8-e4010727c662")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
130 changes: 130 additions & 0 deletions tests/FSharp.MetadataFormat.Tests/files/csharpSupport/SampleClass.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace csharpSupport
{
/// <summary>
/// My_Static_Sample_Class
/// </summary>
public static class SampleStaticClass
{
/// <summary>
/// My_Static_Method
/// </summary>
public static void StaticMethod() { }


/// <summary>
/// My_Static_Property
/// </summary>
public static string StaticProperty { get; set; }

/// <summary>
/// My_Static_Event
/// </summary>
public static event EventHandler StaticEvent;

/// <summary>
/// My_Private_Static_Method
/// </summary>
private static void StaticPrivateMethod() { }


/// <summary>
/// My_Private_Static_Property
/// </summary>
private static string StaticPrivateProperty { get; set; }

/// <summary>
/// My_Private_Static_Event
/// </summary>
private static event EventHandler StaticPrivateEvent;
}

/// <summary>
/// My_Sample_Class
/// </summary>
public class SampleClass
{
/// <summary>
/// My_Static_Method
/// </summary>
public static void StaticMethod() { }


/// <summary>
/// My_Static_Property
/// </summary>
public static string StaticProperty { get; set; }

/// <summary>
/// My_Static_Event
/// </summary>
public static event EventHandler StaticEvent;


/// <summary>
/// My_Private_Static_Method
/// </summary>
private static void StaticPrivateMethod() { }


/// <summary>
/// My_Private_Static_Property
/// </summary>
private static string StaticPrivateProperty { get; set; }

/// <summary>
/// My_Private_Static_Event
/// </summary>
private static event EventHandler StaticPrivateEvent;


/// <summary>
/// My_Constructor
/// </summary>
public SampleClass() { }

/// <summary>
/// My_Method
/// </summary>
public void Method() { }


/// <summary>
/// My_Property
/// </summary>
public string Property { get; set; }

/// <summary>
/// My_Event
/// </summary>
public event EventHandler Event;


/// <summary>
/// My_Private_Constructor
/// </summary>
private SampleClass(int dummy) { }


/// <summary>
/// My_Private_Method
/// </summary>
private void PrivateMethod() { }


/// <summary>
/// My_Private_Property
/// </summary>
private string PrivateProperty { get; set; }

/// <summary>
/// My_Private_Event
/// </summary>
private event EventHandler PrivateEvent;
}
}
Loading