Exemplo n.º 1
0
        public void SetPropertyValueTest()
        {
            BuildFile bf = TestData.BuildFile;

            bf.SetPropertyValue("OutputDir", "TestSetOutputDir");

            Assert.AreEqual(@"TestSetOutputDir", bf.GetPropertyValue("OutputDir"));

            Assert.AreEqual(false, bf.SetPropertyValue("nonexistantproperty", "TestSetOutputDir"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Checks the current rule on the given build file.
        /// </summary>
        /// <param name="project">The build file to verify.</param>
        /// <returns>The log entries for the specified build file.</returns>
        public override IList <LogEntry> Check(BuildFile project)
        {
            List <LogEntry> entries = new List <LogEntry>();

            foreach (string condition in new string[] { "Debug", "Release" })
            {
                IList <BuildProperty> properties = project.FindProperties("DocumentationFile", condition);
                if (properties.Count == 0)
                {
                    LogEntry entry = CreateMissingDocumentationFileLogEntry(condition);
                    entries.Add(entry);
                }
                else
                {
                    foreach (BuildProperty property in properties)
                    {
                        if (string.IsNullOrEmpty(property.Value))
                        {
                            LogEntry entry = CreateMissingDocumentationFileLogEntry(condition);
                            entries.Add(entry);
                        }
                        else
                        {
                            string outputPath    = project.GetPropertyValue("OutputPath", condition);
                            string expectedValue = Path.Combine(outputPath, project.GetPropertyValue("AssemblyName")) + ".xml";
                            if (!string.Equals(expectedValue, property.Value, StringComparison.OrdinalIgnoreCase))
                            {
                                string message = string.Format(CultureInfo.CurrentCulture, "The documentation file has an incorrect file name.");
                                string detail  = string.Format(CultureInfo.CurrentCulture, "The XML documentation file is named \"{0}\" but it should be \"{1}\"", property.Value, expectedValue);
                                entries.Add(new LogEntry(Name, "IncorrectFileName", LogLevel.Error, message, detail));
                            }
                        }
                    }
                }
            }

            return(entries);
        }
Exemplo n.º 3
0
 public void GetPropertyValueShouldThrowOnEmptyName()
 {
     BuildFile file = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
     file.GetPropertyValue("");
 }
Exemplo n.º 4
0
        public void GetPropertyValueTest()
        {
            BuildFile bf = TestData.BuildFile;

            Assert.AreEqual(@"C:\Temp\TestTool", bf.GetPropertyValue("OutputDir"));
        }
Exemplo n.º 5
0
        public void BuildFileConstructorShouldInitializePropertiesCollection()
        {
            BuildFile file = new BuildFile(@"BuildFiles\DefaultConsoleApplication.csproj");
            Assert.IsNotNull(file.Properties);
            Assert.AreEqual<int>(22, file.Properties.Count);

            // Test properties.
            IList<BuildProperty> properties;
            properties = file.FindProperties("DebugType");
            Assert.AreEqual<int>(2, properties.Count);
            Assert.AreEqual<string>("full", properties[0].Value);
            Assert.AreEqual<string>("pdbonly", properties[1].Value);

            properties = file.FindProperties("DebugType", "debug");
            Assert.AreEqual<int>(1, properties.Count);
            Assert.AreEqual<string>("full", properties[0].Value);

            // Test regular property values.
            Assert.AreEqual<string>("Debug", file.GetPropertyValue("Configuration"));
            Assert.AreEqual<string>("AnyCPU", file.GetPropertyValue("Platform"));
            Assert.AreEqual<string>("8.0.50727", file.GetPropertyValue("ProductVersion"));
            Assert.AreEqual<string>("8.0.50727", file.GetPropertyValue("ProductVersion", null));
            Assert.AreEqual<string>("8.0.50727", file.GetPropertyValue("ProductVersion", ""));

            // Test invalid property values, e.g. because of case sensitivity.
            Assert.IsNull(file.GetPropertyValue("configuration"));
            Assert.IsNull(file.GetPropertyValue("Configuration "));

            // Test invalid conditions.
            Assert.IsNull(file.GetPropertyValue("ProductVersion", "dummy"));
            Assert.AreEqual<bool>(true, file.GetPropertyValueAsBoolean("DebugSymbols", "dummy", true));
            Assert.AreEqual<bool>(false, file.GetPropertyValueAsBoolean("DebugSymbols", "dummy", false));

            // Test valid conditions.
            Assert.AreEqual<string>("true", file.GetPropertyValue("DebugSymbols", "debug"));
            Assert.AreEqual<bool>(true, file.GetPropertyValueAsBoolean("DebugSymbols", "debug", false));
            Assert.AreEqual<string>("full", file.GetPropertyValue("DebugType", "debug"));
            Assert.AreEqual<string>("pdbonly", file.GetPropertyValue("DebugType", "release"));
        }