public void PackagePropertiesOverrideAssemblyInfo()
        {
            var project = new Project
            {
                AssemblyAttributes   = BaseAssemblyAttributes(),
                PackageConfiguration = new PackageConfiguration()
                {
                    Copyright   = "Some different copyright",
                    Description = "Some other description",
                    Version     = "1.5.2-otherVersion"
                },
                Deletions      = new List <FileSystemInfo>(),
                PropertyGroups = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Company", "TheCompany Inc."),
                new XElement("Description", "Some other description"),
                new XElement("Product", "The Product"),
                new XElement("Copyright", "Some different copyright"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.5.2-otherVersion"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("NeutralLanguage", "someLanguage"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration",
                Trademark     = "A trademark",
                Culture       = "A culture"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));
            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
        public void BlankEntriesGetDeleted()
        {
            var baseAssemblyAttributes = BaseAssemblyAttributes();

            baseAssemblyAttributes.Company         = "";
            baseAssemblyAttributes.Copyright       = "";
            baseAssemblyAttributes.Description     = "";
            baseAssemblyAttributes.Trademark       = "";
            baseAssemblyAttributes.Culture         = "";
            baseAssemblyAttributes.NeutralLanguage = "";

            var project = new Project
            {
                AssemblyAttributes = baseAssemblyAttributes,
                Deletions          = new List <FileSystemInfo>(),
                PropertyGroups     = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Product", "The Product"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.8.4.3-beta.1"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
        public void MovesAttributesToCsProj()
        {
            var project = new Project
            {
                AssemblyAttributes = BaseAssemblyAttributes(),
                Deletions          = new List <FileSystemInfo>(),
                PropertyGroups     = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Company", "TheCompany Inc."),
                new XElement("Description", "A description"),
                new XElement("Product", "The Product"),
                new XElement("Copyright", "A Copyright notice  ©"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.8.4.3-beta.1"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9"),
                new XElement("NeutralLanguage", "someLanguage"),
                new XElement("SignAssembly", "true"),
                new XElement("DelaySign", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PublicKey.snk"),
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration",
                Trademark     = "A trademark",
                Culture       = "A culture"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.AreEqual(project.AssemblyAttributeProperties.ToList(), project.PrimaryPropertyGroup().Elements().ToArray());

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
Beispiel #4
0
        public void PackagePropertiesOverrideAssemblyInfo()
        {
            var project = new Project
            {
                AssemblyAttributes   = BaseAssemblyAttributes(),
                PackageConfiguration = new PackageConfiguration()
                {
                    Copyright   = "Some different copyright",
                    Description = "Some other description",
                    Version     = "1.5.2-otherVersion"
                },
                Deletions = new List <FileSystemInfo>()
            };

            var transform = new AssemblyAttributeTransformation();

            transform.Transform(project, new Progress <string>());

            var expectedProperties = new[]
            {
                new XElement("AssemblyTitle", "The Title"),
                new XElement("Company", "TheCompany Inc."),
                new XElement("Description", "Some other description"),
                new XElement("Product", "The Product"),
                new XElement("Copyright", "Some different copyright"),
                new XElement("GenerateAssemblyConfigurationAttribute", false),
                new XElement("Version", "1.5.2-otherVersion"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                new XElement("FileVersion", "1.1.7.9")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes
            {
                Configuration = "SomeConfiguration"
            };

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));
            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
        public void GeneratesAssemblyFileAttributeInCsProj()
        {
            var project = new Project
            {
                AssemblyAttributes = new AssemblyAttributes
                {
                    InformationalVersion = "1.8.4.3-beta.1",
                    //FileVersion should use this. In old projects, this happens automatically
                    //but the converter needs to explicitly copy it
                    Version = "1.0.4.2"
                },
                Deletions      = new List <FileSystemInfo>(),
                PropertyGroups = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("Version", "1.8.4.3-beta.1"),
                new XElement("AssemblyVersion", "1.0.4.2"),
                //Should be copied from assembly version
                new XElement("FileVersion", "1.0.4.2")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes();

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }
        public void GeneratesSignAssemblyAttributeInCsProj()
        {
            var project = new Project
            {
                AssemblyAttributes = new AssemblyAttributes
                {
                    KeyFile = "PrivateKey.snk"
                },
                Deletions      = new List <FileSystemInfo>(),
                PropertyGroups = ProjectPropertyGroups
            };

            var transform = new AssemblyAttributeTransformation(NoopLogger.Instance);

            transform.Transform(project);

            var expectedProperties = new[]
            {
                new XElement("SignAssembly", "true"),
                new XElement("AssemblyOriginatorKeyFile", "PrivateKey.snk")
            }
            .Select(x => x.ToString())
            .ToList();

            var actualProperties = project.AssemblyAttributeProperties
                                   .Select(x => x.ToString())
                                   .ToList();

            CollectionAssert.AreEquivalent(expectedProperties, actualProperties);

            var expectedAttributes = new AssemblyAttributes();

            Assert.IsTrue(expectedAttributes.Equals(project.AssemblyAttributes));

            CollectionAssert.DoesNotContain(project.Deletions?.ToList(), BaseAssemblyAttributes().File);
        }