<commit_before>﻿using System.IO;
using System.Reflection;
using NUnit.Framework;

namespace NUnit.VisualStudio.TestAdapter.Tests
{
    [Category("Navigation")]
    public class NavigationDataTests
    {
        NavigationDataProvider _provider;

        const string Prefix = "NUnit.VisualStudio.TestAdapter.Tests.NavigationTestData";

        [SetUp]
        public void SetUp()
        {
            _provider = new NavigationDataProvider(
                typeof(NavigationDataTests).GetTypeInfo().Assembly.Location);
        }

        [TearDown]
        public void TearDown()
        {
            _provider.Dispose();
        }

        [TestCase("", "EmptyMethod_OneLine", 9, 9)]
        [TestCase("", "EmptyMethod_TwoLines", 12, 13)]
        [TestCase("", "EmptyMethod_ThreeLines", 16, 17)]
        [TestCase("", "EmptyMethod_LotsOfLines", 20, 23)]
        [TestCase("", "SimpleMethod_Void_NoArgs", 26, 28)]
        [TestCase("", "SimpleMethod_Void_OneArg", 32, 33)]
        [TestCase("", "SimpleMethod_Void_TwoArgs", 38, 39)]
        [TestCase("", "SimpleMethod_ReturnsInt_NoArgs", 44, 46)]
        [TestCase("", "SimpleMethod_ReturnsString_OneArg", 50, 51)]
        // Generic method uses simple name
        [TestCase("", "GenericMethod_ReturnsString_OneArg", 55, 56)]
        [TestCase("", "AsyncMethod_Void", 60, 62)]
        [TestCase("", "AsyncMethod_Task", 67, 69)]
        [TestCase("", "AsyncMethod_ReturnsInt", 74, 76)]
        // Nested classes use ECMA-335 format
        [TestCase("/NestedClass", "SimpleMethod_Void_NoArgs", 83, 85)]
        [TestCase("/ParameterizedFixture", "SimpleMethod_ReturnsString_OneArg", 101, 102)]
        // Generic Fixture requires ` plus type arg count
        [TestCase("/GenericFixture`2", "Matches", 116, 117)]
        [TestCase("/GenericFixture`2/DoublyNested", "WriteBoth", 132, 133)]
        [TestCase("/GenericFixture`2/DoublyNested`1", "WriteAllThree", 151, 152)]
        [TestCase("/DerivedClass", "EmptyMethod_ThreeLines", 160, 161)]
        // Handles sub class format from Type.FullName
        [TestCase("+NestedClass", "SimpleMethod_Void_NoArgs", 83, 85)]
        [TestCase("+GenericFixture`2+DoublyNested", "WriteBoth", 132, 133)]
        [TestCase("+GenericFixture`2+DoublyNested`1", "WriteAllThree", 151, 152)]
        public void VerifyNavigationData_WithinAssembly(string suffix, string methodName, int expectedLineDebug, int expectedLineRelease)
        {
            VerifyNavigationData(suffix, methodName, "NUnitTestAdapterTests", expectedLineDebug, expectedLineRelease);
        }
      
#if !NETCOREAPP1_0
        // .NET Standard does not have the assembly resolvers, so the fixes for this do not work
        [TestCase("/DerivedFromExternalAbstractClass", "EmptyMethod_ThreeLines", 6, 7)]
        [TestCase("/DerivedFromExternalConcreteClass", "EmptyMethod_ThreeLines", 13, 14)]
        public void VerifyNavigationData_WithExternalAssembly(string suffix, string methodName, int expectedLineDebug, int expectedLineRelease)
        {
#if LAUNCH_DEBUGGER
            if (!Debugger.IsAttached) { Debugger.Launch(); }
#endif
            VerifyNavigationData(suffix, methodName, "NUnit3AdapterExternalTests", expectedLineDebug, expectedLineRelease);
        }
#endif

        private void VerifyNavigationData(string suffix, string methodName, string expectedDirectory, int expectedLineDebug, int expectedLineRelease)
        {<commit_msg>Stop accommodating Mono.Cecil's ECMA format for nested classes<commit_after>﻿using System.IO;
using System.Reflection;
using NUnit.Framework;

namespace NUnit.VisualStudio.TestAdapter.Tests
{
    [Category("Navigation")]
    public class NavigationDataTests
    {
        NavigationDataProvider _provider;

        const string Prefix = "NUnit.VisualStudio.TestAdapter.Tests.NavigationTestData";

        [SetUp]
        public void SetUp()
        {
            _provider = new NavigationDataProvider(
                typeof(NavigationDataTests).GetTypeInfo().Assembly.Location);
        }

        [TearDown]
        public void TearDown()
        {
            _provider.Dispose();
        }

        [TestCase("", "EmptyMethod_OneLine", 9, 9)]
        [TestCase("", "EmptyMethod_TwoLines", 12, 13)]
        [TestCase("", "EmptyMethod_ThreeLines", 16, 17)]
        [TestCase("", "EmptyMethod_LotsOfLines", 20, 23)]
        [TestCase("", "SimpleMethod_Void_NoArgs", 26, 28)]
        [TestCase("", "SimpleMethod_Void_OneArg", 32, 33)]
        [TestCase("", "SimpleMethod_Void_TwoArgs", 38, 39)]
        [TestCase("", "SimpleMethod_ReturnsInt_NoArgs", 44, 46)]
        [TestCase("", "SimpleMethod_ReturnsString_OneArg", 50, 51)]
        // Generic method uses simple name
        [TestCase("", "GenericMethod_ReturnsString_OneArg", 55, 56)]
        [TestCase("", "AsyncMethod_Void", 60, 62)]
        [TestCase("", "AsyncMethod_Task", 67, 69)]
        [TestCase("", "AsyncMethod_ReturnsInt", 74, 76)]
        // Nested classes use Type.FullName format
        [TestCase("+NestedClass", "SimpleMethod_Void_NoArgs", 83, 85)]
        [TestCase("+ParameterizedFixture", "SimpleMethod_ReturnsString_OneArg", 101, 102)]
        // Generic Fixture requires ` plus type arg count
        [TestCase("+GenericFixture`2", "Matches", 116, 117)]
        [TestCase("+GenericFixture`2+DoublyNested", "WriteBoth", 132, 133)]
        [TestCase("+GenericFixture`2+DoublyNested`1", "WriteAllThree", 151, 152)]
        [TestCase("+DerivedClass", "EmptyMethod_ThreeLines", 160, 161)]
        public void VerifyNavigationData_WithinAssembly(string suffix, string methodName, int expectedLineDebug, int expectedLineRelease)
        {
            VerifyNavigationData(suffix, methodName, "NUnitTestAdapterTests", expectedLineDebug, expectedLineRelease);
        }
      
#if !NETCOREAPP1_0
        // .NET Standard does not have the assembly resolvers, so the fixes for this do not work
        [TestCase("+DerivedFromExternalAbstractClass", "EmptyMethod_ThreeLines", 6, 7)]
        [TestCase("+DerivedFromExternalConcreteClass", "EmptyMethod_ThreeLines", 13, 14)]
        public void VerifyNavigationData_WithExternalAssembly(string suffix, string methodName, int expectedLineDebug, int expectedLineRelease)
        {
            VerifyNavigationData(suffix, methodName, "NUnit3AdapterExternalTests", expectedLineDebug, expectedLineRelease);
        }
#endif

        private void VerifyNavigationData(string suffix, string methodName, string expectedDirectory, int expectedLineDebug, int expectedLineRelease)
        {
{'fraction_non_alphanumeric': 0.1183159188690842, 'fraction_numerical': 0.03318992009834051, 'mean_word_length': 3.554933519944017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2005824', 'n_tokens_mistral': 1997, 'n_tokens_neox': 1775, 'n_words': 417}