Beispiel #1
0
            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.Contains("using System.Runtime.CompilerServices;", result);
                Assert.Contains("[assembly: InternalsVisibleTo(\"Assembly1.Tests\")]", result);
            }
Beispiel #2
0
            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);
        }
Beispiel #4
0
            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);
            }