public override void TestsStarting(object sender, TestEventArgs <UnitTestMethod> args)
        {
            ConsoleMethod       test  = args.Test;
            TestSuiteDefinition suite = GetTestSuiteDefinition(test);

            SetTestSuiteExecutionSummary(suite);
        }
Esempio n. 2
0
        public TestResult(ConsoleMethod cim, TestType testType = Testing.TestType.Unit) : this()
        {
            MethodInfo method = cim.Method;

            MethodName       = method.Name;
            Description      = cim.Information;
            AssemblyFullName = method.DeclaringType.Assembly.FullName;
            Passed           = true;
            TestType         = testType.ToString();
        }
Esempio n. 3
0
 private static void TryInvoke <T>(ConsoleMethod cim)
 {
     try
     {
         cim.Invoke();
     }
     catch (Exception ex)
     {
         OutLineFormat("Exception in {0} method {1}: {2}", ConsoleColor.Magenta, typeof(T).Name, cim.Method.Name, ex.Message);
     }
 }
Esempio n. 4
0
        public static void AddKeyword(string name, ConsoleMethod method = null, int minimumParameters = -1, string help = "")
        {
            if (!Proxy.IsPlaying())
            {
                return;
            }
            ConsoleCallback call = new ConsoleCallback();

            call.basic             = method;
            call.help              = help;
            call.minimumParameters = minimumParameters;
            Console.AddKeyword(name, call);
        }
Esempio n. 5
0
        private static string GetSuiteTitle(ConsoleMethod test)
        {
            if (test == null || test.Method == null)
            {
                throw new ArgumentNullException("test");
            }
            string title = GetSuiteTitle(test.Method.DeclaringType);

            if (test.Method.HasCustomAttributeOfType(out TestSuiteAttribute methodAttr))
            {
                title = methodAttr.Title;
            }
            return(title);
        }
Esempio n. 6
0
        private static string GetSuiteTitle(ConsoleMethod test)
        {
            Args.ThrowIfNull(test);
            Args.ThrowIfNull(test.Method);
            Type   containingType = test.Method.DeclaringType;
            string title          = $"{containingType.Assembly.FullName}:{containingType.Name}";

            if (containingType.HasCustomAttributeOfType(out TestSuiteAttribute typeAttr))
            {
                title = typeAttr.Title;
            }
            else if (test.Method.HasCustomAttributeOfType(out TestSuiteAttribute methodAttr))
            {
                title = methodAttr.Title;
            }
            return(title);
        }
        /// <summary>
        /// Get a TestSuiteDefinition for the specified test creating it if necessary
        /// and populating the internal cache
        /// </summary>
        /// <param name="test"></param>
        /// <returns></returns>
        protected TestSuiteDefinition GetTestSuiteDefinition(ConsoleMethod test)
        {
            TestSuiteDefinition suite = TestSuiteDefinition.FromMethod(test);

            if (!_testSuiteDefinitionLookupByTitle.TryGetValue(suite.Title, out suite))
            {
                GetSuiteDefinitionResponse response = TestReportService.GetSuiteDefinition(suite.Title);
                if (response.Success)
                {
                    _testSuiteDefinitionLookupByTitle.TryAdd(suite.Title, response.SuiteDefinition);
                }
                else
                {
                    Logger.Warning("Failed to define test suite: {0}", response.Message);
                }
            }

            return(suite);
        }
Esempio n. 8
0
        protected internal static void InvokeTest(ConsoleMethod consoleMethod, Func <MethodInfo, object[]> parameterProvider, bool isolateMethodCalls = true)
        {
            object[]   parameters   = parameterProvider(consoleMethod.Method);
            MethodInfo invokeTarget = typeof(ConsoleMethod).GetMethod("Invoke");

            if (consoleMethod.Method.IsStatic)
            {
                if (isolateMethodCalls)
                {
                    CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod);
                }
                else
                {
                    CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod);
                }
            }
            else
            {
                string          typeName = consoleMethod.Method.DeclaringType.Name;
                ConstructorInfo ctor     = consoleMethod.Method.DeclaringType.GetConstructor(Type.EmptyTypes);
                if (ctor == null)
                {
                    ExceptionHelper.ThrowInvalidOperation("The declaring type {0} of method {1} does not have a parameterless constructor, test cannot be run.", typeName, consoleMethod.Method.Name);
                }

                object instance = ctor.Invoke(null);
                Expect.IsNotNull(instance, string.Format("Unable to instantiate declaring type {0} of method {1}", typeName, consoleMethod.Method.Name));

                consoleMethod.Provider = instance;
                if (isolateMethodCalls)
                {
                    CommandLineInterface.InvokeInSeparateAppDomain(invokeTarget, consoleMethod);
                }
                else
                {
                    CommandLineInterface.InvokeInCurrentAppDomain(invokeTarget, consoleMethod);
                }
            }
        }
        /// <summary>
        /// Get a TestSuiteDefinition for the specified test creating it if necessary
        /// and populating the internal cache
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        protected TestSuiteDefinition GetTestSuiteDefinition <TTestMethod>(TestEventArgs <TTestMethod> args) where TTestMethod : TestMethod
        {
            ConsoleMethod       test  = args.Test;
            TestSuiteDefinition suite = TestSuiteDefinition.FromTestEventArgs(args);

            if (!_testSuiteDefinitionLookupByTitle.TryGetValue(suite.Title, out TestSuiteDefinition fromCache))
            {
                GetSuiteDefinitionResponse response = TestReportService.GetSuiteDefinition(suite.Title);
                if (response.Success)
                {
                    _testSuiteDefinitionLookupByTitle.TryAdd(suite.Title, response.SuiteDefinition);
                }
                else
                {
                    Logger.Warning("Failed to define test suite: {0}", response.Message);
                }
            }
            if (fromCache != null)
            {
                suite = fromCache;
            }
            return(suite);
        }
Esempio n. 10
0
		public Vector3Command (ConsoleMethod method):base(method){}
Esempio n. 11
0
 public static TestSuiteDefinition FromMethod(ConsoleMethod test)
 {
     return(new TestSuiteDefinition {
         Title = GetSuiteTitle(test)
     });
 }
 public List <ConsoleMethod> GetBeforeAllMethods(Assembly assembly)
 {
     return(ConsoleMethod.FromAssembly <BeforeUnitTests>(assembly));
 }
 public List <ConsoleMethod> GetBeforeEachMethods(Assembly assembly)
 {
     return(ConsoleMethod.FromAssembly <BeforeEachUnitTest>(assembly));
 }
Esempio n. 14
0
 public ParamsCommand(ConsoleMethod method) : base(method)
 {
 }
Esempio n. 15
0
		public Vector3Command (ConsoleMethod method, string helpText):base(method, helpText){}
Esempio n. 16
0
 public Command(ConsoleMethod method) : base(method)
 {
 }
Esempio n. 17
0
		public Vector2Command (string name, ConsoleMethod method, string helpText):base(name, method, helpText){}
Esempio n. 18
0
 public CommandParams(string title, ConsoleMethod method) : base(title, method)
 {
 }
Esempio n. 19
0
 public Command(string title, ConsoleMethod method, string helpText) : base(title, method, helpText)
 {
 }
Esempio n. 20
0
 public Vector3Command(string name, ConsoleMethod method, HelpMethod helpMethod) : base(name, method, helpMethod)
 {
 }
Esempio n. 21
0
 public Vector3Command(string name, ConsoleMethod method, string helpText) : base(name, method, helpText)
 {
 }
Esempio n. 22
0
		public Vector3Command (ConsoleMethod method, HelpMethod helpMethod):base(method, helpMethod){}
Esempio n. 23
0
		public Vector3Command (string name, ConsoleMethod method, HelpMethod helpMethod):base(name, method, helpMethod){}
Esempio n. 24
0
 public Command(ConsoleMethod method, HelpMethod helpMethod) : base(method, helpMethod)
 {
 }
Esempio n. 25
0
 public Vector3Command(ConsoleMethod method) : base(method)
 {
 }
Esempio n. 26
0
		public Vector2Command (string name, ConsoleMethod method):base(name, method){}
Esempio n. 27
0
 public CommandParams(ConsoleMethod method) : base(method)
 {
 }
Esempio n. 28
0
 public Vector2Command(string name, ConsoleMethod method) : base(name, method)
 {
 }
Esempio n. 29
0
 public Command(string title, ConsoleMethod method, HelpMethod helpMethod) : base(title, method, helpMethod)
 {
 }
Esempio n. 30
0
 public ParamsCommand(string name, ConsoleMethod method, HelpMethod helpMethod) : base(name, method, helpMethod)
 {
 }
Esempio n. 31
0
 public Command(ConsoleMethod method, string helpText) : base(method, helpText)
 {
 }
 public List <ConsoleMethod> GetAfterAllMethods(Assembly assembly)
 {
     return(ConsoleMethod.FromAssembly <AfterUnitTests>(assembly));
 }
Esempio n. 33
0
 public ParamsCommand(string name, ConsoleMethod method, string helpText) : base(name, method, helpText)
 {
 }
Esempio n. 34
0
 public static void AddCvarMethod(string name, object scope, string dataName, string fullName = "", string help = "", ConsoleMethod method = null)
 {
     if (!Proxy.IsPlaying())
     {
         return;
     }
     Console.AddCvar(name, scope, dataName, fullName, help);
     Console.cvars[name].method.basic = method;
 }