コード例 #1
0
ファイル: ReflectionHelper.cs プロジェクト: Mhburg/MUnit
        /// <summary>
        /// Resolve full name for this test cycle.
        /// </summary>
        /// <param name="type"> From which this test cycle is constructed. </param>
        /// <param name="scope"> Scope of this test cycle. </param>
        /// <returns> Full name of this test cycle. </returns>
        internal string ResolveTestCycleFullName(Type type, TestCycleScope scope)
        {
            string fullName = string.Empty;

            switch (scope)
            {
            case TestCycleScope.AppDomain:
                fullName = Thread.GetDomain().FriendlyName;
                break;

            case TestCycleScope.Assembly:
                fullName = _reflectionWorker.GetAssembly(type).FullName;
                break;

            case TestCycleScope.Namespace:
                // Namespace can be null if a type is defined outside any namespace keyword.
                fullName = _reflectionWorker.GetNamespace(type) ?? Resources.Strings.NoNamespace;
                break;

            case TestCycleScope.Class:
                fullName = _reflectionWorker.GetTypeFullName(type);
                break;

            case TestCycleScope.Method:
                fullName = this.GetTestCycleNameForMethodScope(type);
                break;
            }

            return(fullName);
        }
コード例 #2
0
ファイル: ReflectionHelper.cs プロジェクト: Mhburg/MUnit
        /// <summary>
        /// Resolve parent ID for this test cycle.
        /// </summary>
        /// <param name="type"> From which this test cycle is constructed. </param>
        /// <param name="scope"> Scope of this test cycle. </param>
        /// <returns> Parent's Guid for this test cycle. </returns>
        /// <remarks> It is called in constructor. Make sure it does not depend on any class members. </remarks>
        internal Guid ResolveParentID(Type type, TestCycleScope scope)
        {
            string fullName = string.Empty;
            string fullPath = _reflectionWorker.GetAssemblyFullPath(type);

            switch (scope)
            {
            case TestCycleScope.AppDomain:
                break;

            case TestCycleScope.Assembly:
                fullName = AppDomain.CurrentDomain.FriendlyName;
                break;

            case TestCycleScope.Namespace:
                fullName = type.Assembly.FullName;
                break;

            case TestCycleScope.Class:
                // Namespace can be null if a type is defined outside any namespace keyword.
                fullName = _reflectionWorker.GetNamespace(type) ?? Resources.Strings.NoNamespace;
                break;

            case TestCycleScope.Method:
                fullName = _reflectionWorker.GetTypeFullName(type);
                break;
            }

            return(HashUtilities.GuidForTestCycleID(fullPath, fullName));
        }
コード例 #3
0
 public TestCycleBase(string source, Type type, TestCycleScope scope)
 {
     this.ParentID = scope == TestCycleScope.AppDomain ? Guid.Empty : ResovleParentID(type, scope);
     this.FullName = ResolveTestCycleFullName(type, scope);
     this.Source   = source;
     this.Scope    = scope;
 }
コード例 #4
0
 public TestCycleBase(string source, Type type, Guid parentID, TestCycleScope scope)
 {
     this.FullName = ResolveTestCycleFullName(type, scope);
     this.ParentID = parentID;
     this.Source   = source;
     this.Scope    = scope;
 }
コード例 #5
0
ファイル: TestCycle.cs プロジェクト: Mhburg/MUnit
 /// <inheritdoc/>
 public override Guid ResovleParentID(Type type, TestCycleScope scope)
 {
     return(_reflectionHelper.ResolveParentID(type, scope));
 }
コード例 #6
0
ファイル: TestCycle.cs プロジェクト: Mhburg/MUnit
 /// <inheritdoc/>
 public override string ResolveTestCycleFullName(Type type, TestCycleScope scope)
 {
     return(_reflectionHelper.ResolveTestCycleFullName(type, scope));
 }
コード例 #7
0
ファイル: TestCycle.cs プロジェクト: Mhburg/MUnit
 public TestCycle(string source, Type type, Guid parentID, TestCycleScope scope)
     : base(source, type, parentID, scope)
 {
 }
コード例 #8
0
ファイル: TestCycle.cs プロジェクト: Mhburg/MUnit
 public TestCycle(string source, Type type, TestCycleScope scope)
     : base(source, type, scope)
 {
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestCycleBase"/> class.
 /// </summary>
 /// <param name="source">Source name of the test.</param>
 /// <param name="type"> The type from which this test cycle is constructed. </param>
 /// <param name="parentID">ID of parent test cycle.</param>
 /// <param name="scope">Scope of this test cycle.</param>
 /// <param name="displayName">Name to display in UI.</param>
 public TestCycleBase(string source, Type type, Guid parentID, TestCycleScope scope, string displayName)
     : this(source, type, parentID, scope)
 {
     _displayName = displayName;
 }