Exemple #1
0
        void Init()
        {
            TestId             = test.Id?.ToString();
            sourceCodeLocation = new SourceCodeLocation(test.CodeFilePath, test.LineNumber, 0);

            int index = test.FullyQualifiedName.LastIndexOf('.');

            if (index > 0)
            {
                FixtureTypeName = test.FullyQualifiedName.Substring(0, index);

                index = FixtureTypeName.LastIndexOf('.');
                if (index > 0)
                {
                    FixtureTypeNamespace = FixtureTypeName.Substring(0, index);
                    FixtureTypeName      = FixtureTypeName.Substring(index + 1);
                }
                else
                {
                    FixtureTypeNamespace = String.Empty;
                }
            }
            else
            {
                FixtureTypeNamespace = String.Empty;
                FixtureTypeName      = String.Empty;
            }

            index = test.DisplayName.LastIndexOf('.');
            if (index > 0)
            {
                name = test.DisplayName.Substring(index + 1);
            }
            else
            {
                name = test.DisplayName;
            }
        }
Exemple #2
0
        void Init()
        {
            TestId = test.Id.ToString();
            TestSourceCodeDocumentId = test.FullyQualifiedName;
            if (!string.IsNullOrEmpty(test.CodeFilePath))
            {
                sourceCodeLocation = new SourceCodeLocation(test.CodeFilePath, test.LineNumber, 0);
            }
            else
            {
                IdeApp.TypeSystemService.GetCompilationAsync(Project).ContinueWith((t) => {
                    var dotIndex     = test.FullyQualifiedName.LastIndexOf(".", StringComparison.Ordinal);
                    var className    = test.FullyQualifiedName.Remove(dotIndex);
                    var methodName   = test.FullyQualifiedName.Substring(dotIndex + 1);
                    var bracketIndex = methodName.IndexOf('(');
                    if (bracketIndex != -1)
                    {
                        methodName = methodName.Remove(bracketIndex).Trim();
                    }
                    var compilation = t.Result;
                    if (compilation == null)
                    {
                        return;
                    }
                    var cls = compilation.GetTypeByMetadataName(className);
                    if (cls == null)
                    {
                        return;
                    }
                    IMethodSymbol method = null;
                    while ((method = cls.GetMembers(methodName).OfType <IMethodSymbol> ().FirstOrDefault()) == null)
                    {
                        cls = cls.BaseType;
                        if (cls == null)
                        {
                            return;
                        }
                    }
                    if (method == null)
                    {
                        return;
                    }
                    var source = method.Locations.FirstOrDefault(l => l.IsInSource);
                    if (source == null)
                    {
                        return;
                    }
                    var line           = source.GetLineSpan();
                    sourceCodeLocation = new SourceCodeLocation(source.SourceTree.FilePath, line.StartLinePosition.Line, line.StartLinePosition.Character);
                }).Ignore();
            }
            int index = test.FullyQualifiedName.LastIndexOf('.');

            if (index > 0)
            {
                FixtureTypeName = test.FullyQualifiedName.Substring(0, index);

                index = FixtureTypeName.LastIndexOf('.');
                if (index > 0)
                {
                    FixtureTypeNamespace = FixtureTypeName.Substring(0, index);
                    FixtureTypeName      = FixtureTypeName.Substring(index + 1);
                }
                else
                {
                    FixtureTypeNamespace = string.Empty;
                }
            }
            else
            {
                FixtureTypeNamespace = string.Empty;
                FixtureTypeName      = string.Empty;
            }
            name = test.DisplayName;
            var obsoletePrefix = string.IsNullOrEmpty(FixtureTypeNamespace) ? FixtureTypeName : FixtureTypeNamespace + "." + FixtureTypeName;

            if (test.DisplayName.StartsWith(obsoletePrefix, StringComparison.Ordinal) && test.DisplayName [obsoletePrefix.Length] == '.')
            {
                name = test.DisplayName.Substring(obsoletePrefix.Length + 1);
            }
        }