public void SetPropertyTest() { CodeSweep.VSPackage.BuildManager_Accessor accessor = new CodeSweep.VSPackage.BuildManager_Accessor(_serviceProvider); Microsoft.Build.Evaluation.Project project = Utilities.SetupMSBuildProject(); MockIVsProject vsProject = Utilities.RegisterProjectWithMocks(project, _serviceProvider); accessor.SetProperty(vsProject, "foo", "bar"); Assert.AreEqual("bar", accessor.GetProperty(vsProject, "foo"), "SetProperty did not set value correctly."); accessor.SetProperty(vsProject, "foo", ""); Assert.AreEqual("", accessor.GetProperty(vsProject, "foo"), "SetProperty did not set value correctly (2)."); }
public void SetPropertyWithInvalidArgs() { CodeSweep.VSPackage.BuildManager_Accessor accessor = new CodeSweep.VSPackage.BuildManager_Accessor(_serviceProvider); bool thrown = Utilities.HasFunctionThrown <ArgumentNullException>(delegate { accessor.SetProperty(null, "foo", "bar"); }); Assert.IsTrue(thrown, "SetProperty did not throw ArgumentNullException with null project arg."); Microsoft.Build.Evaluation.Project project = Utilities.SetupMSBuildProject(); MockIVsProject vsProject = Utilities.RegisterProjectWithMocks(project, _serviceProvider); thrown = Utilities.HasFunctionThrown <ArgumentNullException>(delegate { accessor.SetProperty(vsProject, null, "bar"); }); Assert.IsTrue(thrown, "SetProperty did not throw ArgumentNullException with null name arg."); thrown = Utilities.HasFunctionThrown <ArgumentNullException>(delegate { accessor.SetProperty(vsProject, "foo", null); }); Assert.IsTrue(thrown, "SetProperty did not throw ArgumentNullException with null value arg."); thrown = Utilities.HasFunctionThrown <ArgumentException>(delegate { accessor.SetProperty(vsProject, "", "bar"); }); Assert.IsTrue(thrown, "SetProperty did not throw ArgumentException with empty name arg."); }