Exemple #1
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"));
        }