Exemplo n.º 1
0
    public void VerifyCommentWorksCSharp([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.cs")))
        {
            writer.Write(@"
using System;
using System.Reflection;

//[assembly: {0}(""1.0.0.0"")]
", attribute);
        }

        InvalidFileChecker.CheckForInvalidFiles(new[] { "AssemblyInfo.cs" }, projectFile);
    }
Exemplo n.º 2
0
    public void VerifyIgnoreNonAssemblyInfoFile()
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "SomeOtherFile.cs")))
        {
            writer.Write(@"
using System;
using System.Reflection;

[assembly: AssemblyVersion(""1.0.0.0"")]
");
        }

        InvalidFileChecker.CheckForInvalidFiles(new[] { "SomeOtherFile.cs" }, projectFile);
    }
Exemplo n.º 3
0
    public void VerifyCommentWorksVisualBasic([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.vb")))
        {
            writer.Write(@"
Imports System
Imports System.Reflection

'<Assembly: {0}(""1.0.0.0"")>
", attribute);
        }

        InvalidFileChecker.CheckForInvalidFiles(new[] { "AssemblyInfo.vb" }, projectFile);
    }
Exemplo n.º 4
0
    public void VerifyAttributeFoundCSharp([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion", "System.Reflection.AssemblyVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.cs")))
        {
            writer.Write(@"
using System;
using System.Reflection;

[assembly:{0}(""1.0.0.0"")]
", attribute);
        }

        var ex = Assert.Throws <WarningException>(() => InvalidFileChecker.CheckForInvalidFiles(new[] { "AssemblyInfo.cs" }, projectFile), attribute);

        Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs"));
    }
    public void VerifyIdentifierWorksVisualBasic([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.vb")))
        {
            writer.Write(@"
Imports System
Imports System.Reflection

Public Class {0}
End Class
", attribute);
        }

        InvalidFileChecker.CheckForInvalidFiles(new ITaskItem[] { new MockTaskItem {
                                                                      ItemSpec = "AssemblyInfo.vb"
                                                                  } }, projectFile);
    }
    public void VerifyAttributeFoundVisualBasic([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion", "System.Reflection.AssemblyVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.vb")))
        {
            writer.Write(@"
Imports System
Imports System.Reflection

<Assembly:{0}(""1.0.0.0"")>
", attribute);
        }

        var ex = Assert.Throws <WarningException>(() => InvalidFileChecker.CheckForInvalidFiles(new ITaskItem[] { new MockTaskItem {
                                                                                                                      ItemSpec = "AssemblyInfo.vb"
                                                                                                                  } }, projectFile), attribute);

        Assert.That(ex.Message, Is.EqualTo("File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb"));
    }
    public void VerifyIdentifierWorksCSharp([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.cs")))
        {
            writer.Write(@"
using System;
using System.Reflection;

public class {0}
{{
}}
", attribute);
        }

        InvalidFileChecker.CheckForInvalidFiles(new ITaskItem[] { new MockTaskItem {
                                                                      ItemSpec = "AssemblyInfo.cs"
                                                                  } }, projectFile);
    }
    public void VerifyStringWorksCSharp([Values("AssemblyVersion", "AssemblyFileVersion", "AssemblyInformationalVersion")] string attribute)
    {
        using (var writer = File.CreateText(Path.Combine(projectDirectory, "AssemblyInfo.cs")))
        {
            writer.Write(@"
using System;
using System.Reflection;

public class Temp
{{
    static const string Foo = ""[assembly: {0}(""""1.0.0.0"""")]"";
}}
", attribute);
        }

        InvalidFileChecker.CheckForInvalidFiles(new ITaskItem[] { new MockTaskItem {
                                                                      ItemSpec = "AssemblyInfo.cs"
                                                                  } }, projectFile);
    }