public void Should_Throw_If_Settings_Are_Null() { // Given var fixture = new AssemblyInfoFixture(); var creator = new AssemblyInfoCreator(fixture.FileSystem, fixture.Environment, fixture.Log); // When var result = Record.Exception(() => creator.Create("A.cs", null)); // Then Assert.IsArgumentNullException(result, "settings"); }
public void Should_Make_Relative_Output_Path_Absolute() { // Given var fixture = new AssemblyInfoFixture(); var creator = new AssemblyInfoCreator(fixture.FileSystem, fixture.Environment, fixture.Log); // When creator.Create("AssemblyInfo.cs", new AssemblyInfoSettings()); // Then Assert.True(fixture.FileSystem.Exist((FilePath)"/Working/AssemblyInfo.cs")); }
public void Should_Throw_If_Output_Path_Is_Null() { // Given var fixture = new AssemblyInfoFixture(); var creator = new AssemblyInfoCreator(fixture.FileSystem, fixture.Environment, fixture.Log); // When var result = Record.Exception(() => creator.Create(null, new AssemblyInfoSettings())); // Then Assert.IsArgumentNullException(result, "outputPath"); }
public void Should_Add_Configuration_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.Configuration = "TheConfiguration"; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System.Reflection;")); Assert.True(result.Contains("[assembly: AssemblyConfiguration(\"TheConfiguration\")]")); }
public void Should_Add_InternalsVisibleTo_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.InternalsVisibleTo = new List<string> { "Assembly1.Tests" }; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System.Runtime.CompilerServices;")); Assert.True(result.Contains("[assembly: InternalsVisibleTo(\"Assembly1.Tests\")]")); }
public void Should_Add_CLSCompliant_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.CLSCompliant = true; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System;")); Assert.True(result.Contains("[assembly: CLSCompliant(true)]")); }
public void Should_Add_ComVisible_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.ComVisible = true; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System.Runtime.InteropServices;")); Assert.True(result.Contains("[assembly: ComVisible(true)]")); }
public void Should_Add_Trademark_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.Trademark = "TheTrademark"; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System.Reflection;")); Assert.True(result.Contains("[assembly: AssemblyTrademark(\"TheTrademark\")]")); }
public void Should_Add_Guid_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.Guid = "TheGuid"; // When var result = fixture.CreateAndReturnContent(); // Then Assert.True(result.Contains("using System.Runtime.InteropServices;")); Assert.True(result.Contains("[assembly: Guid(\"TheGuid\")]")); }
public void Should_Add_CustomAttributes_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.AddCustomAttribute("TestAttribute", "Test.NameSpace", "TestValue"); // When var result = fixture.CreateAndReturnContent(); // Then Assert.Contains("using Test.NameSpace;", result); Assert.Contains("[assembly: TestAttribute(\"TestValue\")]", result); }
public void Should_Add_InformationalVersion_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.InformationalVersion = "TheInformationalVersion"; // When var result = fixture.CreateAndReturnContent(); // Then Assert.Contains("using System.Reflection;", result); Assert.Contains("[assembly: AssemblyInformationalVersion(\"TheInformationalVersion\")]", result); }
public void Should_Add_Copyright_Attribute_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.Copyright = "TheCopyright"; // When var result = fixture.CreateAndReturnContent(); // Then Assert.Contains("using System.Reflection;", result); Assert.Contains("[assembly: AssemblyCopyright(\"TheCopyright\")]", result); }
public void Should_Read_CustomAttributes() { // Given var fixture = new AssemblyInfoParserFixture(); fixture.CustomAttributes = new List <AssemblyInfoCustomAttribute> { new AssemblyInfoCustomAttribute { Name = "FooA", NameSpace = "SomeFoos.Attributes", Value = "A Value" }, new AssemblyInfoCustomAttribute { Name = "FooB", NameSpace = "SomeFoos.Attributes", Value = true } }; // When var result = fixture.Parse(); var assemblyInfoFixture = new AssemblyInfoFixture(); assemblyInfoFixture.Settings = new AssemblyInfoSettings() { CustomAttributes = result.CustomAttributes, CLSCompliant = result.ClsCompliant, Company = result.Company, ComVisible = result.ComVisible, Configuration = result.Configuration, Copyright = result.Copyright, Description = result.Description, FileVersion = result.AssemblyFileVersion, Guid = result.Guid, InformationalVersion = result.AssemblyInformationalVersion, InternalsVisibleTo = result.InternalsVisibleTo, Product = result.Product, Title = result.Title, Trademark = result.Trademark, Version = result.AssemblyVersion }; var result2 = assemblyInfoFixture.CreateAndReturnContent(); // Then //Assert.Equal(2, result.InternalsVisibleTo.Count); //Assert.Equal("Cake.Core.Tests", result.InternalsVisibleTo.ElementAt(0)); //Assert.Equal("Cake.Common.Tests", result.InternalsVisibleTo.ElementAt(1)); }
public void Should_Add_MetadataAttributes_If_Set() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.AddMetadataAttribute("Key1", "TestValue1"); fixture.Settings.AddMetadataAttribute("Key2", "TestValue2"); fixture.Settings.AddMetadataAttribute("Key1", "TestValue3"); // When var result = fixture.CreateAndReturnContent(); // Then Assert.Contains("using System.Reflection;", result); Assert.Contains("[assembly: AssemblyMetadata(\"Key1\", \"TestValue3\")]", result); Assert.Contains("[assembly: AssemblyMetadata(\"Key2\", \"TestValue2\")]", result); Assert.DoesNotContain("[assembly: AssemblyMetadata(\"Key1\", \"TestValue1\")]", result); }
public void Should_Add_CustomAttributes_If_Set_With_Empty_Value() { // Given var fixture = new AssemblyInfoFixture(); fixture.Settings.CustomAttributes = new Collection <AssemblyInfoCustomAttribute> { new AssemblyInfoCustomAttribute { Name = "TestAttribute", NameSpace = "Test.NameSpace", Value = string.Empty } }; // When var result = fixture.CreateAndReturnContent(); // Then Assert.Contains("using Test.NameSpace;", result); Assert.Contains("[assembly: TestAttribute()]", result); }