/// <summary> /// Returns whether the parameter project is a test project or not. /// </summary> public static bool IsTestProject(this IVsProject project, Guid projectGuid) { // Overload IsTestProject method to check if we should use this test adapter // at all. This is much less error prone than adding this check to all locations // where this method is called. if (!IsTestAdapaterEnabled()) { return(false); } ValidateArg.NotNull(project, "project"); var projectTypeGuids = project.GetAggregateProjectTypeGuids(); // Currently we assume that all matching projects are test projects. return(projectTypeGuids.IndexOf(projectGuid.ToString(), StringComparison.OrdinalIgnoreCase) >= 0); }
/// <summary> /// Updates the description of an opt-in channel in the given guild. /// </summary> /// <param name="guildConnection"> /// The connection to the guild this channel is being created in. May not be null. /// </param> /// <param name="guildData">Information about this guild. May not be null.</param> /// <param name="requestAuthor">The author of the channel create request. May not be null.</param> /// <param name="channelName">The current name of the channel to rename. May not be null.</param> /// <param name="description">The requested description of the channel.</param> /// <returns>The result of the request.</returns> public static async Task <UpdateDescriptionResult> UpdateDescription( SocketGuild guildConnection, Guild guildData, SocketGuildUser requestAuthor, string channelName, string description) { ValidateArg.IsNotNullOrWhiteSpace(channelName, nameof(channelName)); if (!guildData.OptinParentCategory.HasValue) { return(UpdateDescriptionResult.NoOptinCategory); } var optinsCategory = guildData.OptinParentCategory.GetValueOrDefault(); // Check that the request author has permission to create opt-ins (which means they can update their description as well) var hasPermission = PermissionsUtilities.HasPermission( userRoles: requestAuthor.Roles.Select(x => new Snowflake(x.Id)), allowedRoles: guildData.OptinCreatorsRoles); if (!hasPermission) { return(UpdateDescriptionResult.NoPermissions); } var optinsCategoryConnection = guildConnection.GetCategoryChannel(optinsCategory.Value); // Try to get the channel to update and verify it exists var currentChannel = optinsCategoryConnection.Channels .Where(x => string.Compare(x.Name, channelName, ignoreCase: true) == 0 && x is SocketTextChannel) .Cast <SocketTextChannel>() .SingleOrDefault(); if (currentChannel == default) { return(UpdateDescriptionResult.NoSuchChannel); } // Modify the channel description await currentChannel.ModifyAsync(settings => { settings.Topic = description ?? string.Empty; }).ConfigureAwait(false); return(UpdateDescriptionResult.Success); }
/// <summary> /// Initializes a new instance of the <see cref="AwesomeInventoryLoadout"/> class. /// </summary> /// <param name="pawn"> Initialize <see cref="AwesomeInventoryLoadout"/> with items on this <paramref name="pawn"/>. </param> public AwesomeInventoryLoadout(Pawn pawn) { ValidateArg.NotNull(pawn, nameof(pawn)); this.AddItems(pawn.equipment?.AllEquipmentListForReading); this.AddItems(pawn.apparel?.WornApparel); this.AddItems(pawn.inventory?.innerContainer); this.uniqueId = Current.Game.outfitDatabase.AllOutfits.Max(o => o.uniqueId) + 1; CompAwesomeInventoryLoadout compLoadout = pawn.TryGetComp <CompAwesomeInventoryLoadout>(); this.label = compLoadout?.Loadout == null ? AwesomeInventoryLoadout.GetDefaultLoadoutName(pawn) : LoadoutManager.GetIncrementalLabel(compLoadout.Loadout.label); pawn.SetLoadout(this); }
public static double[][] ExponentialWeightMatrix(double[][] d, double exponent) { ValidateArg.IsNotNull(d, "d"); double[][] w = new double[d.Length][]; for (int i = 0; i < d.Length; i++) { w[i] = new double[d[i].Length]; for (int j = 0; j < d[i].Length; j++) { if (d[i][j] > 0) { w[i][j] = Math.Pow(d[i][j], exponent); } } } return(w); }
/// <summary> /// Initializes a new instance of the <see cref="GenericAmmo"/> class. /// </summary> /// <param name="defName"> Def Name. </param> /// <param name="description"> Description for this def. </param> /// <param name="label"> Label to display. </param> /// <param name="thingClass"> Type of Thing that this def defines. </param> /// <param name="ammoDefs"> A list of ammo defs. </param> public GenericAmmo(string defName, string description, string label, Type thingClass, IEnumerable <AmmoDef> ammoDefs) : base(defName, description, label, thingClass, ammoDefs.SelectMany(t => t.thingCategories).Distinct(), null) { ValidateArg.NotNull(ammoDefs, nameof(ammoDefs)); this.statBases = new List <StatModifier>() { new StatModifier() { stat = StatDefOf.Mass, value = ammoDefs.Average(t => t.GetStatValueAbstract(StatDefOf.Mass)), }, new StatModifier() { stat = CE_StatDefOf.Bulk, value = ammoDefs.Average(t => t.GetStatValueAbstract(CE_StatDefOf.Bulk)), }, }; }
/// <summary> /// Sends the event to all data collectors and fires a callback on the sender, letting it /// know when all plugins have completed processing the event /// </summary> /// <param name="args">The context information for the event</param> private void SendEvent(DataCollectionEventArgs args) { ValidateArg.NotNull(args, nameof(args)); if (!this.isDataCollectionEnabled) { if (EqtTrace.IsErrorEnabled) { EqtTrace.Error("DataCollectionManger:SendEvent: SendEvent called when no collection is enabled."); } return; } // do not send events multiple times this.events.RaiseEvent(args); }
public void RemoveWatch(string path) { ValidateArg.NotNullOrEmpty(path, "path"); if (!string.IsNullOrEmpty(path)) { FileWatcherInfo watcherInfo; if (this.fileWatchers.TryRemove(path, out watcherInfo)) { watcherInfo.Watcher.EnableRaisingEvents = false; watcherInfo.Watcher.Changed -= this.OnChanged; watcherInfo.Watcher.Dispose(); watcherInfo.Watcher = null; } } }
private void OnTestCaseEnd(object sender, TestCaseEndEventArgs e) { ValidateArg.NotNull(e, "TestCaseEndEventArgs"); Debug.Assert(e.Context != null, "Context is null"); Debug.Assert(e.Context.HasTestCase, "Context is not for a test case"); if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose( "EventLogDataCollector: TestCaseEnd received for test '{0}' with Test Outcome: {1}.", e.TestCaseName, e.TestOutcome); } this.WriteCollectedEventLogEntries(e.Context, false, TimeSpan.MaxValue, DateTime.UtcNow); }
/// <summary> /// calculates new curve ends that are the arrowhead starts /// </summary> /// <param name="edgeGeometry">The edgeGeometry.Curve is trimmed already by the node boundaries</param> /// <returns></returns> internal static bool CalculateArrowheads(EdgeGeometry edgeGeometry) { ValidateArg.IsNotNull(edgeGeometry, "edgeGeometry"); if (edgeGeometry.SourceArrowhead == null && edgeGeometry.TargetArrowhead == null) { return(true); } double parStart, parEnd; if (!FindTrimStartForArrowheadAtSource(edgeGeometry, out parStart)) { return(false); } if (!FindTrimEndForArrowheadAtTarget(edgeGeometry, out parEnd)) { return(false); } if (parStart > parEnd - ApproximateComparer.IntersectionEpsilon || ApproximateComparer.CloseIntersections(edgeGeometry.Curve[parStart], edgeGeometry.Curve[parEnd])) { return(false); //after the trim nothing would be left of the curve } var c = edgeGeometry.Curve.Trim(parStart, parEnd); if (c == null) { return(false); } if (edgeGeometry.SourceArrowhead != null) { edgeGeometry.SourceArrowhead.TipPosition = PlaceTip(c.Start, edgeGeometry.Curve.Start, edgeGeometry.SourceArrowhead.Offset); } if (edgeGeometry.TargetArrowhead != null) { edgeGeometry.TargetArrowhead.TipPosition = PlaceTip(c.End, edgeGeometry.Curve.End, edgeGeometry.TargetArrowhead.Offset); } edgeGeometry.Curve = c; return(true); }
//SharpKit/Colin - https://code.google.com/p/sharpkit/issues/detail?id=290 public int Compare(LayerEdge a, LayerEdge b) { #else int System.Collections.Generic.IComparer <LayerEdge> .Compare(LayerEdge a, LayerEdge b) { #endif ValidateArg.IsNotNull(a, "a"); ValidateArg.IsNotNull(b, "b"); int r = X[a.Target] - X[b.Target]; if (r != 0) { return(r); } return(X[a.Source] - X[b.Source]); } }
/// <summary> /// Registers to receive events from the provided test run request. /// These events will then be broadcast to any registered loggers. /// </summary> /// <param name="testRunRequest">The run request to register for events on.</param> public void RegisterTestRunEvents(ITestRunRequest testRunRequest) { ValidateArg.NotNull <ITestRunRequest>(testRunRequest, "testRunRequest"); this.CheckDisposed(); // Keep track of the run requests so we can unregister for the // events when disposed. this.runRequest = testRunRequest; // Redirect the events to the InternalTestLoggerEvents testRunRequest.TestRunMessage += this.TestRunMessageHandler; testRunRequest.OnRunStart += this.TestRunStartHandler; testRunRequest.OnRunStatsChange += this.TestRunStatsChangedHandler; testRunRequest.OnRunCompletion += this.TestRunCompleteHandler; testRunRequest.DataCollectionMessage += this.DataCollectionMessageHandler; }
/// <inheritdoc /> public override void Update(StatEntryModel model) { ValidateArg.NotNull(model, nameof(model)); if (model == _lastModel) { return; } if (model.StatDef == _lastModel.StatDef && model.Selected == _lastModel.Selected) { return; } _lastModel = new StatEntryModel(model); this.NeedBuild = true; }
/// <summary> /// Initializes a new instance of the <see cref="ThingGroupSelector"/> class. /// </summary> /// <param name="other"> Copy <paramref name="other"/> to this selector. </param> public ThingGroupSelector(ThingGroupSelector other) { ValidateArg.NotNull(other, nameof(other)); this.GroupID = LoadoutManager.ThingGroupSelectorID; this.AllowedStackCount = other.AllowedStackCount; this.AllowedThing = other.AllowedThing; _bottomThresholdCount = other._bottomThresholdCount; _useBottomThreshold = other._useBottomThreshold; foreach (ThingSelector thingSelector in other._selectors) { Type selectorType = thingSelector.GetType(); ThingSelector newSelector = (ThingSelector)Activator.CreateInstance(selectorType, new object[] { thingSelector }); this.Add(newSelector); } }
public int Compare(SegmentBase a, SegmentBase b) { ValidateArg.IsNotNull(b, "b"); var orient = Point.GetTriangleOrientation(b.Start, b.End, x); switch (orient) { case TriangleOrientation.Collinear: return(0); case TriangleOrientation.Clockwise: return(1); default: return(-1); } }
/// <summary> /// Match test case with filter criteria. /// </summary> public bool MatchTestCase(TestCase testCase, Func <string, Object> propertyValueProvider) { ValidateArg.NotNull(testCase, "testCase"); ValidateArg.NotNull(propertyValueProvider, "propertyValueProvider"); if (!this.validForMatch) { return(false); } if (null == this.filterWrapper) { // can be null when parsing error occurs. Invalid filter results in no match. return(false); } return(this.filterWrapper.Evaluate(propertyValueProvider)); }
/// <summary> /// For a set of nodes and edges that have not already been added to a graph will return an enumerable of new /// graphs each of which contains a connected component. /// </summary> /// <remarks> /// Debug.Asserts that Parent of nodes and edges has not yet been assigned to ensure that this is not being /// applied to nodes and edges that have already been added to a graph. Applying this to such edges would /// result in the Node InEdges and OutEdges lists containing duplicates. /// </remarks> /// <returns></returns> public static IEnumerable <GeometryGraph> CreateComponents(IList <Node> nodes, IEnumerable <Edge> edges) { ValidateArg.IsNotNull(nodes, "nodes"); ValidateArg.IsNotNull(edges, "edges"); var nodeIndex = new Dictionary <Node, int>(); int nodeCount = 0; foreach (var v in nodes) // Debug.Assert(v.Parent == null, "Node is already in a graph"); { nodeIndex[v] = nodeCount++; } var intEdges = new List <SimpleIntEdge>(); foreach (var e in edges) // Debug.Assert(e.Parent == null, "Edge is already in a graph"); { intEdges.Add(new SimpleIntEdge { Source = nodeIndex[e.Source], Target = nodeIndex[e.Target] }); } var components = ConnectedComponentCalculator <SimpleIntEdge> .GetComponents(new BasicGraph <SimpleIntEdge>(intEdges, nodeCount)); var nodeToGraph = new Dictionary <Node, GeometryGraph>(); var graphs = new List <GeometryGraph>(); foreach (var c in components) { var g = new GeometryGraph(); foreach (var i in c) { var v = nodes[i]; g.Nodes.Add(v); nodeToGraph[v] = g; } graphs.Add(g); } foreach (var e in edges) { var g = nodeToGraph[e.Source]; Debug.Assert(nodeToGraph[e.Target] == g, "source and target of edge are not in the same graph"); g.Edges.Add(e); } return(graphs); }
/// <summary> /// Add pickup option to context menu when right-click on items on map. /// </summary> /// <param name="clickPos"> Position of the mouse when right-click. </param> /// <param name="pawn"> Currently focused pawn. </param> /// <param name="opts"> Options displayed in context menu. </param> public static void Postfix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { ValidateArg.NotNull(pawn, nameof(pawn)); ValidateArg.NotNull(opts, nameof(opts)); if (pawn.IsQuestLodger()) { return; } IntVec3 position = IntVec3.FromVector3(clickPos); List <Thing> items = position.GetThingList(pawn.Map); if (!PickUpAndHaulUtility.IsActive) { foreach (Thing item in items) { if (item.def.category == ThingCategory.Item) { int count = MassUtility.CountToPickUpUntilOverEncumbered(pawn, item); if (count == 0) { continue; } count = Math.Min(count, item.stackCount); string displayText = UIText.Pickup.Translate(item.LabelNoCount + " x" + count); var option = FloatMenuUtility.DecoratePrioritizedTask( new FloatMenuOption( displayText , () => { Job job = JobMaker.MakeJob(JobDefOf.TakeInventory, item); job.count = count; job.checkEncumbrance = true; pawn.jobs.TryTakeOrderedJob(job); }) , pawn , item); opts.Add(option); } } } }
public static double[] Multiply(double[][] A, double[] x) { ValidateArg.IsNotNull(A, "A"); ValidateArg.IsNotNull(x, "x"); if (A[0].Length != x.Length) { return(null); } double[] y = new double[x.Length]; for (int i = 0; i < A.Length; i++) { for (int j = 0; j < A[0].Length; j++) { y[i] += A[i][j] * x[j]; } } return(y); }
/// <summary> /// Creates singleton instance of DataCollectionRequestHandler. /// </summary> /// <param name="communicationManager"> /// Handles socket communication. /// </param> /// <param name="messageSink"> /// Message sink for sending messages to execution process. /// </param> /// <returns> /// The instance of <see cref="DataCollectionRequestHandler"/>. /// </returns> public static DataCollectionRequestHandler Create(ICommunicationManager communicationManager, IMessageSink messageSink) { if (Instance == null) { ValidateArg.NotNull(communicationManager, nameof(communicationManager)); ValidateArg.NotNull(messageSink, nameof(messageSink)); lock (syncObject) { if (Instance == null) { Instance = new DataCollectionRequestHandler(communicationManager, messageSink, DataCollectionManager.Create(messageSink), new DataCollectionTestCaseEventHandler()); } } } return(Instance); }
/// <summary> /// Runs only the tests specified by parameter 'tests'. /// </summary> /// <param name="tests">Tests to be run.</param> /// <param name="runContext">Context to use when executing the tests.</param> /// <param name="frameworkHandle">Handle to the framework to record results and to do framework operations.</param> public void RunTests(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle) { ValidateArg.NotNull(tests, nameof(tests)); ValidateArg.NotNull(frameworkHandle, nameof(frameworkHandle)); ICollection <Guid> runningTests = tests.Select(t => t.Id).ToList(); if (!Client.Connected) { Client.Start(); } List <string> sources = tests.Select(t => t.Source).ToList(); sources.ForEach((source) => { bool result = Client.CheckAssemblyHash(source, out _, out _); }); Client.DiscoverTests(sources); this.RunTestsInternal(runningTests, frameworkHandle); }
/// <summary> /// This is the equivalent of "RunAll" functionality /// </summary> /// <param name="sources">Refers to the list of test sources passed to the test adapter from the client. (Client could be VS or command line)</param> public void RunTests(IEnumerable <string> sources, ITestDiscoverer discoverer) { ValidateArg.NotNull(sources, nameof(sources)); ValidateArg.NotNull(discoverer, nameof(discoverer)); this.cancelRequested.Reset(); var receiver = new TestReceiver(); discoverer.DiscoverTests(sources, this.runContext, this.frameworkHandle, receiver); if (this.cancelRequested.WaitOne(0)) { return; } this.RunTests(receiver.Tests); }
/// <summary> /// Initializes a new instance of the <see cref="TestRunCriteria"/> class. /// </summary> /// /// <param name="adapterSourceMap"> /// Sources which contains tests that should be executed. /// </param> /// <param name="frequencyOfRunStatsChangeEvent">Frequency of run stats event.</param> /// <param name="keepAlive"> /// Whether the execution process should be kept alive after the run is finished or not. /// </param> /// <param name="testSettings">Settings used for this run.</param> /// <param name="runStatsChangeEventTimeout"> /// Timeout that triggers sending results regardless of cache size. /// </param> /// <param name="testHostLauncher"> /// Test host launcher. If null then default will be used. /// </param> public TestRunCriteria( Dictionary <string, IEnumerable <string> > adapterSourceMap, long frequencyOfRunStatsChangeEvent, bool keepAlive, string testSettings, TimeSpan runStatsChangeEventTimeout, ITestHostLauncher testHostLauncher) : base( frequencyOfRunStatsChangeEvent, keepAlive, testSettings, runStatsChangeEventTimeout, testHostLauncher) { ValidateArg.NotNullOrEmpty(adapterSourceMap, nameof(adapterSourceMap)); this.AdapterSourceMap = adapterSourceMap; }
private void OnTestCaseStart(object sender, TestCaseStartEventArgs e) { ValidateArg.NotNull(e, "TestCaseStartEventArgs"); ValidateArg.NotNull(e.Context, "TestCaseStartEventArgs.Context"); if (!e.Context.HasTestCase) { Debug.Fail("Context is not for a test case"); throw new ArgumentNullException("TestCaseStartEventArgs.Context.HasTestCase"); } if (EqtTrace.IsVerboseEnabled) { EqtTrace.Verbose("EventLogDataCollector: TestCaseStart received for test '{0}'.", e.TestCaseName); } this.StartCollectionForContext(e.Context, false); }
/// <summary> /// This is the equivalent of "Run Selected Tests" functionality. /// </summary> /// <param name="tests">The list of TestCases selected to run</param> public void RunTests(IEnumerable <TestCase> tests) { ValidateArg.NotNull(tests, nameof(tests)); this.cancelRequested.Reset(); var testFramework = tests.First().GetPropertyValue(JavaScriptTestCaseProperties.TestFramework, defaultValue: TestFrameworkDirectories.ExportRunnerFrameworkName); if (string.Equals(testFramework, TestFrameworkDirectories.AngularFrameworkName, StringComparison.OrdinalIgnoreCase)) { // Every angular run initializes karma, browser, caching, etc, // so is preferable to let the test adapter handle any optimization. RunAllTests(tests); } else { RunTestsByFile(tests); } }
static public RectangleNode <T, P> CreateRectangleNodeOnListOfNodes(IList <RectangleNode <T, P> > nodes) { ValidateArg.IsNotNull(nodes, "nodes"); if (nodes.Count == 0) { return(null); } if (nodes.Count == 1) { return(nodes[0]); } //Finding the seeds //the first seed int seed0 = 1; int seed1 = ChooseSeeds(nodes, ref seed0); //We have two seeds at hand. Build two groups. var gr0 = new List <RectangleNode <T, P> >(); var gr1 = new List <RectangleNode <T, P> >(); gr0.Add(nodes[seed0]); gr1.Add(nodes[seed1]); var box0 = nodes[seed0].Rectangle; var box1 = nodes[seed1].Rectangle; //divide nodes on two groups DivideNodes(nodes, seed0, seed1, gr0, gr1, ref box0, ref box1, GroupSplitThreshold); var ret = new RectangleNode <T, P>(nodes.Count) { Rectangle = box0.Unite(box1), Left = CreateRectangleNodeOnListOfNodes(gr0), Right = CreateRectangleNodeOnListOfNodes(gr1) }; Debug.Assert(RTree <T, P> .TreeIsCorrect(ret)); return(ret); }
public static void DistanceScaling(double[][] d, double[] x, double[] y, double[][] w, int iter) { ValidateArg.IsNotNull(d, "d"); ValidateArg.IsNotNull(x, "x"); ValidateArg.IsNotNull(y, "y"); ValidateArg.IsNotNull(w, "w"); int n = x.Length; double[] wSum = new double[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i != j) { wSum[i] += w[i][j]; } } } System.Console.Write("distance scaling "); for (int c = 0; c < iter; c++) { for (int i = 0; i < n; i++) { double xNew = 0; double yNew = 0; for (int j = 0; j < n; j++) { if (i != j) { double inv = Math.Sqrt(Math.Pow(x[i] - x[j], 2) + Math.Pow(y[i] - y[j], 2)); if (inv > 0) { inv = 1 / inv; } xNew += w[i][j] * (x[j] + d[i][j] * (x[i] - x[j]) * inv); yNew += w[i][j] * (y[j] + d[i][j] * (y[i] - y[j]) * inv); } } x[i] = xNew / wSum[i]; y[i] = yNew / wSum[i]; } } }
public static IXPathNavigable Import(string settingsFile, IXPathNavigable defaultRunSettings, Architecture architecture, FrameworkVersion frameworkVersion) { ValidateArg.NotNull(settingsFile, "settingsFile"); ValidateArg.NotNull(defaultRunSettings, "defaultRunSettings"); if (IsLegacyTestSettingsFile(settingsFile) == false) { throw new XmlException(string.Format(CultureInfo.CurrentCulture, UtilitiesResources.UnExpectedSettingsFile)); } var navigator = defaultRunSettings.CreateNavigator(); if (!navigator.MoveToChild(Constants.RunSettingsName, string.Empty)) { throw new XmlException(UtilitiesResources.NoRunSettingsNodeFound); } var settingsNode = GenerateMSTestXml(settingsFile); settingsNode.MoveToRoot(); navigator.PrependChild(settingsNode); // Adding RunConfig if (!navigator.MoveToChild(Constants.RunConfigurationSettingsName, string.Empty)) { var doc = new XmlDocument(); var runConfigurationNode = doc.CreateElement(Constants.RunConfigurationSettingsName); var targetPlatformNode = doc.CreateElement("TargetPlatform"); targetPlatformNode.InnerXml = architecture.ToString(); runConfigurationNode.AppendChild(targetPlatformNode); var targetFrameworkVersionNode = doc.CreateElement("TargetFrameworkVersion"); targetFrameworkVersionNode.InnerXml = frameworkVersion.ToString(); runConfigurationNode.AppendChild(targetFrameworkVersionNode); var runConfigNodeNavigator = runConfigurationNode.CreateNavigator(); runConfigNodeNavigator.MoveToRoot(); navigator.PrependChild(runConfigNodeNavigator); } navigator.MoveToRoot(); return(navigator); }
public TestContainerDiscoverer(IServiceProvider serviceProvider, SolutionEventsListener solutionListener, IOperationState operationState) { ValidateArg.NotNull(serviceProvider, "serviceProvider"); ValidateArg.NotNull(solutionListener, "solutionListener"); ValidateArg.NotNull(operationState, "operationState"); _projectInfo = new Dictionary <PythonProject, ProjectInfo>(); _serviceProvider = serviceProvider; _solutionListener = solutionListener; _solutionListener.ProjectLoaded += OnProjectLoaded; _solutionListener.ProjectUnloading += OnProjectUnloaded; _solutionListener.ProjectClosing += OnProjectUnloaded; _firstLoad = true; }
/// <summary> /// Updates with code coverage settings if not configured. /// </summary> /// <param name="runSettingsDocument"> The run settings document. </param> public static void UpdateWithCodeCoverageSettingsIfNotConfigured(IXPathNavigable runSettingsDocument) { ValidateArg.NotNull <IXPathNavigable>(runSettingsDocument, "runSettingsDocument"); var runSettingsNavigator = runSettingsDocument.CreateNavigator(); bool codeCoverageConfigured = XmlRunSettingsUtilities.ContainsDataCollector(runSettingsNavigator, DynamicCodeCoverageDataDiagnosticAdaterUriString) || XmlRunSettingsUtilities.ContainsDataCollector(runSettingsNavigator, StaticCodeCoverageDataDiagnosticAdaterUriString); if (codeCoverageConfigured == false) { var existingPath = string.Empty; var xpaths = new string[] { string.Join(xPathSeperator, nodeNames, 0, 1), string.Join(xPathSeperator, nodeNames, 0, 2), string.Join(xPathSeperator, nodeNames, 0, 3) }; foreach (var xpath in xpaths) { if (runSettingsNavigator.SelectSingleNode(xpath) != null) { existingPath = xpath; } else { break; } } // If any nodes are missing to add code coverage deafult settings, add the missing xml nodes. XPathNavigator dataCollectorsNavigator; if (existingPath.Equals(xpaths[2]) == false) { dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(existingPath); var missingNodesText = GetMissingNodesTextIfAny(existingPath, xpaths[2]); dataCollectorsNavigator.AppendChild(missingNodesText); } dataCollectorsNavigator = runSettingsNavigator.SelectSingleNode(xpaths[2]); dataCollectorsNavigator.AppendChild(codeCoverageCollectorSettingsTemplate); } }
/// <summary> /// Computing the minimum enclosing disc the slow stupid way. Just for testing purposes. /// </summary> /// <param name="points"></param> /// <returns>Smallest disc that encloses all the points</returns> public static Disc SlowComputation(Point[] points) { ValidateArg.IsNotNull(points, "points"); int n = points.Length; Disc mc = null; int[] b = null; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i != j) { Disc c = new Disc(points[i], points[j]); if (c.Contains(points, new int[] { i, j })) { if (mc == null || mc.Radius > c.Radius) { mc = c; b = new int[] { i, j }; } } } for (int k = 0; k < n; ++k) { if (k != i && k != j && !Disc.Collinear(points[i], points[j], points[k])) { Disc c3 = new Disc(points[i], points[j], points[k]); if (c3.Contains(points, new int[] { i, j, k })) { if (mc == null || mc.Radius > c3.Radius) { mc = c3; b = new int[] { i, j, k }; } } } } } } Debug.Assert(b != null); return(mc); }