public List <Dependency> ProcessCourse(DependencyType type)
        {
            this._dependencies = new List <Dependency>();
            this.LogMessage(type.ToString());
            // Determine HTML Class
            string filterClass = "prereq";

            if (type == DependencyType.Coreq)
            {
                filterClass = "coreq";
            }
            else if (type == DependencyType.Precoreq)
            {
                filterClass = "precoreq";
            }

            // Filter Based on Class
            string filter = "//ul[@class='" + filterClass + "']//li";

            HtmlNodeCollection coursesHtml = this.content.DocumentNode.SelectNodes(filter);

            // Check if Dependencies Exist
            if (coursesHtml == null)
            {
                return(null);
            }

            //Process Dependencies
            foreach (HtmlNode listItem in coursesHtml)
            {
                string          rawText     = PrepareForProcessing(listItem.InnerHtml);
                Action <string> logCallBack = LogMessage;

                DependencyParser  dependencyParser  = new DependencyParser(rawText, logCallBack);
                List <Dependency> foundDependencies = dependencyParser.GetDependencies();
                if (foundDependencies.Count > 0)
                {
                    _dependencies.AddRange(foundDependencies);
                }
                else
                {
                    this.LogError("Unhandled List Dependency:\n" + listItem.InnerHtml);
                }
            }

            List <Dependency> list = _dependencies;

            this._dependencies = null;
            return(list);
        }
        private static DependencyTypeTestDataPoint CreateDependencyTypeTestDataPointFromEnum(DependencyTypeId enumId)
        {
            DependencyType fromFor = new DependencyType(enumId);

            return(new DependencyTypeTestDataPoint
            {
                ExpectedString = fromFor.ToString(),
                EnumValue = enumId,
                EnumInt = (Int32)enumId,
                EnumName = Enum.GetName(typeof(DependencyTypeId), enumId),
                Id = fromFor.Id,
                Name = fromFor.Name,
                ObjectFromFor = fromFor
            });
        }
        private void VerifyTargetTaskItem(DependencyType type, ITaskItem input, ITaskItem output)
        {
            type.ToString().Should().Be(output.GetMetadata(MetadataKeys.Type));

            // remove unnecessary metadata to keep only ones that would be in result task items
            var removeMetadata = new[] { MetadataKeys.Type, MetadataKeys.ResolvedPath };

            foreach (var rm in removeMetadata)
            {
                output.RemoveMetadata(rm);
                input.RemoveMetadata(rm);
            }

            foreach (var metadata in input.MetadataNames)
            {
                input.GetMetadata(metadata.ToString()).Should().Be(output.GetMetadata(metadata.ToString()));
            }
        }
예제 #4
0
 public void ToString_WhenGivenEnumId_ReturnsCorrectString(DependencyType dependencyType, String expectedString)
 {
     Assert.Equal(expectedString, dependencyType.ToString());
 }
 public static void TrackDependency(this ITelemetry telemetry, DependencyType dependencyType, string dependencyName, DateTimeOffset startTime,
                                    TimeSpan duration, bool success,
                                    Dictionary <string, string> properties = null)
 {
     telemetry.TrackDependency(dependencyType.ToString("G"), dependencyName, startTime, duration, success);
 }