Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestCycleGraph"/> class.
        /// </summary>
        /// <param name="root">Where test cycle stats.</param>
        /// <param name="logger"> Logs information. </param>
        public TestCycleGraph(ITestCycle root, IMUnitLogger logger)
        {
            ThrowUtilities.NullArgument(root, nameof(root));

            _root = root;
            _testCycles.Add(root.ID, root);
            this.Logger = logger;
        }
Example #2
0
        /// <inheritdoc/>
        public virtual void Add(ITestCycle testCycle)
        {
            ThrowUtilities.NullArgument(testCycle, nameof(testCycle));

            _testCycles.Add(testCycle.ID, testCycle);
            if (_testCycles.TryGetValue(testCycle.ParentID, out ITestCycle parent))
            {
                ThrowUtilities.NullMember(parent.Children, nameof(ITestCycle), nameof(parent.Children));
                parent.Children.Add(testCycle);
            }
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TestMethodContext"/> class.
        /// </summary>
        /// <param name="source"> Source where the test is discovered. </param>
        /// <param name="parentCycle"> Test cycle that owns this context. </param>
        /// <param name="method"> Test method to run. </param>
        /// <param name="parentClass"> The class in which test method is declared. </param>
        /// <param name="logger"> Logs information. </param>
        internal TestMethodContext(string source, ITestCycle parentCycle, MethodInfo method, Type parentClass, IMUnitLogger logger)
        {
            Debug.Assert(method != null, "Test method should not be null.");
            Debug.Assert(parentClass != null, "Parent class should not be null.");

            this.Source             = source;
            this.MethodInfo         = method;
            this.DeclaringType      = parentClass;
            this.ParentCycle        = parentCycle;
            this.Logger             = logger;
            this.FullyQualifiedName = FrameworkSerive.RelfectionWoker.GetMethodFullName(method);
            this.TestID             = HashUtilities.GuidForTestCycleID(source, this.FullyQualifiedName);
        }
Example #4
0
        protected virtual void BuildCycleFromAssembly(string source, ITestCycle root, IEnumerable <Type> types, TestCycleCollection testCycles, IMUnitLogger logger)
        {
            ThrowUtilities.NullArgument(root, nameof(root));
            ThrowUtilities.NullArgument(testCycles, nameof(testCycles));
            ThrowUtilities.NullArgument(types, nameof(types));

            TestCycle assemblyCycle = new TestCycle(source, types.First(), root.ID, TestCycleScope.Assembly);

            testCycles.Add(assemblyCycle);
            foreach (Type type in types)
            {
                BuildCycleFromType(source, type, testCycles, logger);
            }
        }
Example #5
0
        /// <summary>
        /// Register the method adorned with this attribute to test cycle.
        /// </summary>
        /// <param name="testCycle">In which the underlying method belongs.</param>
        /// <param name="pType">Preparation type of a method.</param>
        /// <param name="method">Method to register.</param>
        protected static void Register(ITestCycle testCycle, TestCycleMethodType pType, MethodInfo method)
        {
            ThrowUtilities.NullArgument(testCycle, nameof(testCycle));
            ThrowUtilities.NullArgument(method, nameof(method));

            SupportMethodsGroup group = testCycle.SupportMethodsGroups
                                        .FirstOrDefault(g => g.DeclaringType == method.DeclaringType);

            if (group == default)
            {
                group = new SupportMethodsGroup(method.DeclaringType);
                testCycle.SupportMethodsGroups.Add(group);
            }

            if (pType == TestCycleMethodType.Initialize)
            {
                // It will overwrite previously found methods in the same type, if there is any.
                group.InitializeMethod = method;
            }
            else if (pType == TestCycleMethodType.Cleanup)
            {
                group.CleanupMethod = method;
            }
        }
Example #6
0
 /// <inheritdoc/>
 public bool TryGetValue(Guid key, out ITestCycle testCycle)
 {
     return(_testCycles.TryGetValue(key, out testCycle));
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestCycleCollection"/> class.
 /// </summary>
 /// <param name="root">From which test starts.</param>
 /// <param name="logger"> Logs information. </param>
 public TestCycleCollection(ITestCycle root, IMUnitLogger logger)
     : base(root, logger)
 {
 }
Example #8
0
 /// <inheritdoc/>
 public override void Register(ITestCycle testCycle, MethodInfo method)
 {
     Register(testCycle, TestCycleMethodType.Cleanup, method);
 }
Example #9
0
 /// <inheritdoc/>
 public override void Register(ITestCycle testCycle, MethodInfo method)
 {
     Register(testCycle, TestCycleMethodType.Initialize, method);
 }
Example #10
0
 /// <summary>
 /// Register the method adorned with this attribute to test cycle.
 /// </summary>
 /// <param name="testCycle">In which the underlying method belongs.</param>
 /// <param name="method">Method to register.</param>
 public abstract void Register(ITestCycle testCycle, MethodInfo method);