public void TestContradictoryAffinityCausesException_OutOfProc() { Assert.Throws <InvalidOperationException>(() => { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); } ); }
public void TestAffinityChangeAfterClearingHostObject() { HostServices hostServices = new HostServices(); TestHostObject hostObject = new TestHostObject(); hostServices.RegisterHostObject("project", "target", "task", hostObject); Assert.Equal(NodeAffinity.InProc, hostServices.GetNodeAffinity("project")); hostServices.RegisterHostObject("project", "target", "task", null); Assert.Equal(NodeAffinity.Any, hostServices.GetNodeAffinity("project")); hostServices.SetNodeAffinity("project", NodeAffinity.OutOfProc); Assert.Equal(NodeAffinity.OutOfProc, hostServices.GetNodeAffinity("project")); }
/// <summary> /// Creates a build request. /// </summary> private BuildRequest CreateBuildRequest(int nodeRequestId, int configId, string[] targets, NodeAffinity nodeAffinity, BuildRequest parentRequest) { HostServices hostServices = null; if (nodeAffinity != NodeAffinity.Any) { hostServices = new HostServices(); hostServices.SetNodeAffinity(String.Empty, nodeAffinity); } BuildRequest request = new BuildRequest(1 /* submissionId */, nodeRequestId, configId, targets, hostServices, BuildEventContext.Invalid, parentRequest); return(request); }