public void ProjectGlobalPropertyModify() { var pcLocal = this.StdGroup.Local; var pcRemote = this.StdGroup.Remote[0]; var proj1Path = this.StdGroup.StdProjectFiles[0]; var realProj = pcRemote.LoadProject(proj1Path); pcLocal.Importing = true; var viewProj = pcLocal.Collection.GetLoadedProjects(proj1Path).FirstOrDefault(); ProjectPair pair = new ProjectPair(viewProj, realProj); ViewValidation.Verify(pair); Assert.False(pair.View.GlobalProperties.ContainsKey("gp1")); Assert.False(pair.View.GlobalProperties.ContainsKey("Configuration")); // at this point Configuration is not set and gp1 is not set. pair.ValidatePropertyValue("gpt1", "NotFoo"); pair.View.SetGlobalProperty("gp1", "GP1V"); Assert.True(pair.View.GlobalProperties.ContainsKey("gp1")); Assert.True(pair.Real.GlobalProperties.ContainsKey("gp1")); // not evaluated yet. pair.ValidatePropertyValue("gpt1", "NotFoo"); pair.View.ReevaluateIfNecessary(); pair.ValidatePropertyValue("gpt1", "NotFooGP1V"); pair.Real.SetGlobalProperty("Configuration", "Foo"); Assert.True(pair.View.GlobalProperties.ContainsKey("Configuration")); pair.ValidatePropertyValue("gpt1", "NotFooGP1V"); pair.View.ReevaluateIfNecessary(); pair.ValidatePropertyValue("gpt1", "FooGP1V"); }
public void ProjectPropertyModify() { var pcLocal = this.StdGroup.Local; var pcRemote = this.StdGroup.Remote[0]; var proj1Path = this.StdGroup.StdProjectFiles[0]; var realProj = pcRemote.LoadProject(proj1Path); pcLocal.Importing = true; var viewProj = pcLocal.Collection.GetLoadedProjects(proj1Path).FirstOrDefault(); ProjectPair pair = new ProjectPair(viewProj, realProj); ViewValidation.Verify(pair); pair.ValidatePropertyValue("fooProp", string.Empty); var fooView = pair.SetPropertyWithVerify(ObjectType.View, "fooProp", "fooValue$(xxx)"); var fooReal = pair.Real.GetProperty("fooProp"); Assert.Equal("fooValue", fooView.EvaluatedValue); pair.Real.SetGlobalProperty("xxx", "XXX"); Assert.Equal("fooValue", fooView.EvaluatedValue); pair.Real.ReevaluateIfNecessary(); // note msbuild create a new property objects on reevaluation. Assert.Equal("fooValue", fooView.EvaluatedValue); Assert.Equal("fooValue", fooReal.EvaluatedValue); var fooRealNew = pair.Real.GetProperty("fooProp"); var fooViewNew = pair.View.GetProperty("fooProp"); Assert.NotSame(fooReal, fooRealNew); Assert.NotSame(fooView, fooViewNew); Assert.Equal("fooValueXXX", fooViewNew.EvaluatedValue); fooViewNew.UnevaluatedValue = "fooValueChanged$(xxx)"; Assert.Equal("fooValueChanged$(xxx)", fooRealNew.UnevaluatedValue); // but when changing the Unevaluate via ProjectProp element it does update the live object. Assert.Equal("fooValueChangedXXX", fooViewNew.EvaluatedValue); Assert.Equal("fooValueChangedXXX", fooRealNew.EvaluatedValue); ViewValidation.Verify(pair); // note this should work even though the fooView is recycled. Assert.True(pair.View.RemoveProperty(fooView)); Assert.Null(pair.View.GetProperty("fooProp")); }