public KuduXunitTheoryTestCase(IMessageSink diagnosticMessageSink,
                                TestMethodDisplay defaultMethodDisplay,
                                ITestMethod testMethod,
                                IAttributeInfo testAttribute)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
 public KuduXunitTestFrameworkDiscoverer(IAssemblyInfo assemblyInfo,
                                         ISourceInformationProvider sourceProvider,
                                         IMessageSink diagnosticMessageSink,
                                         IXunitTestCollectionFactory collectionFactory = null)
     : base(assemblyInfo, sourceProvider, diagnosticMessageSink, collectionFactory)
 {
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XunitFrontController"/> class.
        /// </summary>
        /// <param name="assemblyFileName">The test assembly.</param>
        /// <param name="configFileName">The test assembly configuration file.</param>
        /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows
        /// <param name="shadowCopyFolder">The path on disk to use for shadow copying; if <c>null</c>, a folder
        /// will be automatically (randomly) generated</param>
        /// <param name="sourceInformationProvider">The source information provider. If <c>null</c>, uses the default (<see cref="T:Xunit.VisualStudioSourceInformationProvider"/>).</param>
        /// tests to be discovered and run without locking assembly files on disk.</param>
        /// <param name="diagnosticMessageSink">The message sink which received <see cref="IDiagnosticMessage"/> messages.</param>
        public XunitFrontController(string assemblyFileName,
                                    string configFileName = null,
                                    bool shadowCopy = true,
                                    string shadowCopyFolder = null,
                                    ISourceInformationProvider sourceInformationProvider = null,
                                    IMessageSink diagnosticMessageSink = null)
        {
            this.assemblyFileName = assemblyFileName;
            this.configFileName = configFileName;
            this.shadowCopy = shadowCopy;
            this.shadowCopyFolder = shadowCopyFolder;
            this.sourceInformationProvider = sourceInformationProvider;
            this.diagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            Guard.FileExists("assemblyFileName", assemblyFileName);

            if (this.sourceInformationProvider == null)
            {
#if !XAMARIN && !WINDOWS_PHONE_APP && !WINDOWS_PHONE && !ASPNET50 && !ASPNETCORE50
                this.sourceInformationProvider = new VisualStudioSourceInformationProvider(assemblyFileName);
#else
                this.sourceInformationProvider = new NullSourceInformationProvider();
#endif
                toDispose.Push(this.sourceInformationProvider);
            }

        }
 public XunitTestAssemblyRunnerWithAssemblyFixture(ITestAssembly testAssembly,
                                                   IEnumerable<IXunitTestCase> testCases,
                                                   IMessageSink diagnosticMessageSink,
                                                   IMessageSink executionMessageSink,
                                                   ITestFrameworkExecutionOptions executionOptions)
     : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
 { }
예제 #5
0
        static Type GetTestFrameworkType(IAssemblyInfo testAssembly, IMessageSink diagnosticMessageSink)
        {
            try
            {
                var testFrameworkAttr = testAssembly.GetCustomAttributes(typeof(ITestFrameworkAttribute)).FirstOrDefault();
                if (testFrameworkAttr != null)
                {
                    var discovererAttr = testFrameworkAttr.GetCustomAttributes(typeof(TestFrameworkDiscovererAttribute)).FirstOrDefault();
                    if (discovererAttr != null)
                    {
                        var discoverer = ExtensibilityPointFactory.GetTestFrameworkTypeDiscoverer(diagnosticMessageSink, discovererAttr);
                        if (discoverer != null)
                            return discoverer.GetTestFrameworkType(testFrameworkAttr);

                        var ctorArgs = discovererAttr.GetConstructorArguments().ToArray();
                        diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Unable to create custom test framework discoverer type '{ctorArgs[1]}, {ctorArgs[0]}'"));
                    }
                    else
                    {
                        diagnosticMessageSink.OnMessage(new DiagnosticMessage("Assembly-level test framework attribute was not decorated with [TestFrameworkDiscoverer]"));
                    }
                }
            }
            catch (Exception ex)
            {
                diagnosticMessageSink.OnMessage(new DiagnosticMessage($"Exception thrown during test framework discoverer construction: {ex.Unwrap()}"));
            }

            return typeof(XunitTestFramework);
        }
            public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
            {
                var methodCallMessage = (IMethodCallMessage)msg;
                try
                {
                    ITransportHeaders requestHeaders;
                    Stream requestStream;
                    SerializeRequestMessage(methodCallMessage, out requestHeaders, out requestStream);

                    var sinkStack = new ClientChannelSinkStack(replySink);
                    sinkStack.Push(this, methodCallMessage);

                    this._nextChannelSink.AsyncProcessRequest(sinkStack, methodCallMessage, requestHeaders, requestStream);
                }
                catch (Exception ex)
                {
                    var errorMessage = new ReturnMessage(ex, methodCallMessage);
                    if (replySink != null)
                    {
                        replySink.SyncProcessMessage(errorMessage);
                    }
                }

                return null;
            }
예제 #7
0
		public static LNode concat_id(LNode node, IMessageSink sink)
		{
			var args = node.Args;
			if (args.Count == 0)
				return null;
			if (args.Slice(0, args.Count - 1).Any(n => n.IsCall))
				return Reject(sink, node, "All arguments to ##() or concat() must be identifiers or literals (except the last one)");

			RVList<LNode> attrs = node.Attrs;
			LNode arg = null;
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < args.Count; i++)
			{
				arg = args[i];
				attrs.AddRange(arg.Attrs);

				if (arg.IsLiteral)
					sb.Append(arg.Value ?? "null");
				else if (arg.IsId)
					sb.Append(arg.Name);
				else { // call
					if (i + 1 != args.Count || !arg.HasSimpleHead())
						return Reject(sink, arg, "Expected simple identifier or literal");
					sb.Append(arg.Name);
				}
			}
			Symbol combined = GSymbol.Get(sb.ToString());
			LNode result;
			if (arg.IsCall)
				result = arg.WithTarget(combined);
			else
				result = LNode.Id(combined, node);
			return result.WithAttrs(attrs);
		}
예제 #8
0
 public MethodCallContext(IMethodCallMessage mcm, IMessageSink nextSink)
 {
     mcm.ThrowIfNullArgument(nameof(mcm));
     nextSink.ThrowIfNullArgument(nameof(nextSink));
     _mcm = mcm;
     _nextSink = nextSink;
 }
 public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink)
 {
     WorkItem work = new WorkItem(reqMsg, this._nextSink, replySink);
     work.SetAsync();
     this._property.HandleWorkRequest(work);
     return null;
 }
예제 #10
0
        Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder,
                         IMessageSink diagnosticMessageSink)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = appDomain.CreateObject<IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            framework = appDomain.CreateObject<ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
예제 #11
0
        /// <summary/>
        public MessageBus(IMessageSink messageSink)
        {
            this.messageSink = messageSink;

            reporterThread = new Thread(ReporterWorker);
            reporterThread.Start();
        }
예제 #12
0
				public CustomProxy( String uri, Type type )
					: base( type )
				{
					// store uri of remote service
					m_uri = uri;

					// pass through registered chanels
					foreach( IChannel channel in ChannelServices.RegisteredChannels ) {
						// and try to find chanel, that can be used to
						// create message sink for given uri
						IChannelSender sender = (IChannelSender) channel;
						if( sender != null ) {
							// check for messaging protocol
							if( sender.ChannelName == "tcp" ) {
								// try to create message sink for specified uri
								string objectUri = string.Empty;
								m_messageSink = sender.CreateMessageSink( m_uri, null, out objectUri );
								// all right, can return
								if( m_messageSink != null )
									break;
							}
						}
					}
					if( m_messageSink == null )
						throw new Exception( "No channel found for " + m_uri );

					// create a unique identifier
					m_clientID = "/310001/" + Guid.NewGuid().ToString();
				}
예제 #13
0
 // Used by Xunit2 when initializing for both discovery and execution.
 internal Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider,
                           string assemblyFileName,
                           string configFileName,
                           bool shadowCopy,
                           string shadowCopyFolder = null,
                           IMessageSink diagnosticMessageSink = null)
     : this(sourceInformationProvider, null, assemblyFileName, GetXunitExecutionAssemblyPath(assemblyFileName), configFileName, shadowCopy, shadowCopyFolder, diagnosticMessageSink) { }
예제 #14
0
		public static LNode ForwardProperty(LNode prop, IMessageSink sink)
		{
			LNode name, fwd, body;
			if (prop.ArgCount != 3)
				return null;
			LNode target = GetForwardingTarget(fwd = prop.Args[2], name = prop.Args[1]);
			if (target != null)
			{
				body = F.Braces(new RVList<LNode>(
					F.Call(S.get, F.Braces(F.Call(S.Return, target))),
					F.Call(S.set, F.Braces(F.Call(S.Assign, target, F.Id(S.value))))));

				return prop.WithArgChanged(2, body);
			}
			else if ((body = fwd).Calls(S.Braces))
			{
				var body2 = body.WithArgs(stmt => {
					if (stmt.Calls(S.get, 1) && (target = GetForwardingTarget(stmt.Args[0], name)) != null)
						return stmt.WithArgs(new RVList<LNode>(F.Braces(F.Call(S.Return, target))));
					if (stmt.Calls(S.set, 1) && (target = GetForwardingTarget(stmt.Args[0], name)) != null)
						return stmt.WithArgs(new RVList<LNode>(F.Braces(F.Call(S.Assign, target, F.Id(S.value)))));
					return stmt;
				});
				if (body2 != body)
					return prop.WithArgChanged(2, body2);
			}
			return null;
		}
 protected RemoteToInternalSpecificationRunListenerAdapter(object listener, string runOptionsXml)
 {
     _listener = (IMessageSink)listener;
     
     this.RunOptions = RunOptions.Parse(runOptionsXml);
     this.Runner = new DefaultRunner(this, RunOptions);
 }
예제 #16
0
		public IListSource<LNode> Parse(IListSource<Token> input, ISourceFile file, IMessageSink msgs, Symbol inputType = null)
		{
			// For efficiency we'd prefer to re-use our _parser object, but
			// when parsing lazily, we can't re-use it because another parsing 
			// operation could start before this one is finished. To force 
			// greedy parsing, we can call ParseStmtsGreedy(), but the caller may 
			// prefer lazy parsing, especially if the input is large. As a 
			// compromise I'll check if the source file is larger than a 
			// certain arbitrary size. Also, ParseExprs() is always greedy 
			// so we can always re-use _parser in that case.
			bool exprMode = inputType == ParsingService.Exprs;
			char _ = '\0';
			if (inputType == ParsingService.Exprs || file.Text.TryGet(255, ref _)) {
				EcsParser parser = _parser;
				if (parser == null)
					_parser = parser = new EcsParser(input, file, msgs);
				else {
					parser.ErrorSink = msgs ?? MessageSink.Current;
					parser.Reset(input, file);
				}
				if (inputType == ParsingService.Exprs)
					return parser.ParseExprs();
				else
					return parser.ParseStmtsGreedy();
			} else {
				var parser = new EcsParser(input, file, msgs);
				return parser.ParseStmtsLazy().Buffered();
			}
		}
예제 #17
0
		public static LNode ForwardMethod(LNode fn, IMessageSink sink)
		{
			LNode args, fwd, body;
			if (fn.ArgCount != 4 || !(fwd = fn.Args[3]).Calls(S.Forward, 1) || !(args = fn.Args[2]).Calls(S.List))
				return null;
			
			RVList<LNode> formalArgs = args.Args;
			RVList<LNode> argList =	RVList<LNode>.Empty;
			foreach (var formalArg in formalArgs)
			{
				if (!formalArg.Calls(S.Var, 2))
					return Reject(sink, formalArg, "'==>' expected a variable declaration here");
				LNode argName = formalArg.Args[1];
				if (argName.Calls(S.Assign, 2))
					argName = argName.Args[0];
				LNode @ref = formalArg.AttrNamed(S.Ref) ?? formalArg.AttrNamed(S.Out);
				if (@ref != null)
					argName = argName.PlusAttr(@ref);
				argList.Add(argName);
			}

			LNode target = GetForwardingTarget(fwd, fn.Args[1]);
			LNode call = F.Call(target, argList);
			
			bool isVoidFn = fn.Args[0].IsIdNamed(S.Void);
			body = F.Braces(isVoidFn ? call : F.Call(S.Return, call));
			return fn.WithArgChanged(3, body);
		}
예제 #18
0
        Xunit2Discoverer(AppDomainSupport appDomainSupport,
                         ISourceInformationProvider sourceInformationProvider,
                         IAssemblyInfo assemblyInfo,
                         string assemblyFileName,
                         string xunitExecutionAssemblyPath,
                         string configFileName,
                         bool shadowCopy,
                         string shadowCopyFolder,
                         IMessageSink diagnosticMessageSink,
                         bool verifyAssembliesOnDisk)
        {
            Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName);
            if (verifyAssembliesOnDisk)
                Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath);

#if PLATFORM_DOTNET
            CanUseAppDomains = false;
#else
            CanUseAppDomains = !IsDotNet(xunitExecutionAssemblyPath);
#endif

            DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink();

            var appDomainAssembly = assemblyFileName ?? xunitExecutionAssemblyPath;
            appDomain = AppDomainManagerFactory.Create(appDomainSupport != AppDomainSupport.Denied && CanUseAppDomains, appDomainAssembly, configFileName, shadowCopy, shadowCopyFolder);

            var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath);

            // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper
            if (assemblyInfo == null)
                assemblyInfo = appDomain.CreateObject<IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName);

            framework = appDomain.CreateObject<ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink);
            discoverer = Framework.GetDiscoverer(assemblyInfo);
        }
예제 #19
0
		public static LNode BackingField(LNode prop, IMessageSink sink)
		{
			LNode type, name, body;
			if (prop.ArgCount != 3 || !(body = prop.Args[2]).Calls(S.Braces))
				return null;

			LNode fieldAttr = null, fieldVarAttr = null;
			LNode fieldName;
			bool autoType = false;
			int i;
			for (i = 0; i < prop.Attrs.Count; i++)
			{
				LNode attr = prop.Attrs[i];
				if (attr.IsIdNamed(_field)
					|| attr.Calls(S.Var, 2) 
						&& ((autoType = attr.Args[0].IsIdNamed(_field)) ||
							(fieldVarAttr = attr.AttrNamed(_field)) != null && fieldVarAttr.IsId))
				{
					fieldAttr = attr;
					break;
				}
			}
			if (fieldAttr == null)
				return null;

			LNode field = fieldAttr;
			type = prop.Args[0];
			if (field.IsId) {
				name = prop.Args[1];
				fieldName = F.Id(ChooseFieldName(Ecs.EcsNodePrinter.KeyNameComponentOf(name)));
				field = F.Call(S.Var, type, fieldName).WithAttrs(fieldAttr.Attrs);
			} else {
				fieldName = field.Args[1];
				if (fieldName.Calls(S.Assign, 2))
					fieldName = fieldName.Args[0];
			}
			if (autoType)
				field = field.WithArgChanged(0, type);
			if (fieldVarAttr != null)
				field = field.WithoutAttrNamed(_field);

			LNode newBody = body.WithArgs(body.Args.SmartSelect(stmt =>
			{
				var attrs = stmt.Attrs;
				if (stmt.IsIdNamed(S.get)) {
					stmt = F.Call(stmt.WithoutAttrs(), F.Braces(F.Call(S.Return, fieldName))).WithAttrs(attrs);
					stmt.BaseStyle = NodeStyle.Special;
				}
				if (stmt.IsIdNamed(S.set)) {
					stmt = F.Call(stmt.WithoutAttrs(), F.Braces(F.Call(S.Assign, fieldName, F.Id(S.value)))).WithAttrs(attrs);
					stmt.BaseStyle = NodeStyle.Special;
				}
				return stmt;
			}));
			if (newBody == body)
				sink.Write(Severity.Warning, fieldAttr, "The body of the property does not contain a 'get;' or 'set;' statement without a body, so no code was generated to get or set the backing field.");

			prop = prop.WithAttrs(prop.Attrs.RemoveAt(i)).WithArgChanged(2, newBody);
			return F.Call(S.Splice, new RVList<LNode>(field, prop));
		}
        public ContextClientSink(object next)
        {
            if (!typeof(IMessageSink).IsInstanceOfType(next))
                throw new ArgumentOutOfRangeException("next");

            _nextSink = (IMessageSink)next;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Xunit.Sdk.XunitTestFrameworkExecutor"/> class.
 /// </summary>
 /// <param name="assemblyName">Name of the test assembly.</param><param name="sourceInformationProvider">The source line number information provider.</param><param name="diagnosticMessageSink">The message sink to report diagnostic messages to.</param>
 public BrowserTestFrameworkExecutor(
     AssemblyName assemblyName,
     ISourceInformationProvider sourceInformationProvider,
     IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
 }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AOPSinkProcessor" /> class.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="nextSink">The next sink.</param>
        /// <param name="messageDelegates">The message delegates.</param>
        public AOPSinkProcessor(MarshalByRefObject sender, IMessageSink nextSink, MessageProcessDelegates messageDelegates)
        {
            this.NextSink = nextSink;
            this.Sender = sender;

            this.messageDelegates = messageDelegates;
        }
예제 #23
0
        /// <inheritdoc/>
        public void Run(IEnumerable<ITestCase> testMethods, IMessageSink messageSink)
        {
            bool cancelled = false;
            var totalSummary = new RunSummary();

            string currentDirectory = Directory.GetCurrentDirectory();

            try
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(assemblyInfo.AssemblyPath));

                if (messageSink.OnMessage(new TestAssemblyStarting()))
                {
                    var classGroups = testMethods.Cast<XunitTestCase>().GroupBy(tc => tc.Class).ToList();

                    if (classGroups.Count > 0)
                    {
                        var collectionSummary = new RunSummary();

                        if (messageSink.OnMessage(new TestCollectionStarting()))
                        {
                            foreach (var group in classGroups)
                            {
                                var classSummary = new RunSummary();

                                if (!messageSink.OnMessage(new TestClassStarting { ClassName = group.Key.Name }))
                                    cancelled = true;
                                else
                                {
                                    cancelled = RunTestClass(messageSink, group, classSummary);
                                    collectionSummary.Aggregate(classSummary);
                                }

                                if (!messageSink.OnMessage(new TestClassFinished { Assembly = assemblyInfo, ClassName = group.Key.Name, TestsRun = classSummary.Total }))
                                    cancelled = true;

                                if (cancelled)
                                    break;
                            }
                        }

                        messageSink.OnMessage(new TestCollectionFinished { Assembly = assemblyInfo, TestsRun = collectionSummary.Total });
                        totalSummary.Aggregate(collectionSummary);
                    }
                }

                messageSink.OnMessage(new TestAssemblyFinished
                {
                    Assembly = assemblyInfo,
                    TestsRun = totalSummary.Total,
                    TestsFailed = totalSummary.Failed,
                    TestsSkipped = totalSummary.Skipped,
                    ExecutionTime = totalSummary.Time
                });
            }
            finally
            {
                Directory.SetCurrentDirectory(currentDirectory);
            }
        }
예제 #24
0
 public InterceptSink(IMessageSink nextSink)
 {
     lock (SyncRoot)
     {
         _nextSink = nextSink;
     }
 }
예제 #25
0
        public BenchmarkTestCase(
                int iterations,
                int warmupIterations,
                string variation,
                IMessageSink diagnosticMessageSink,
                ITestMethod testMethod,
                object[] testMethodArguments)
            : base(diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay.Method, testMethod, null)
        {
            // Override display name to avoid getting info about TestMethodArguments in the
            // name (this is covered by the concept of Variation for benchmarks)
            var suppliedDisplayName = TestMethod.Method.GetCustomAttributes(typeof(FactAttribute))
                .First()
                .GetNamedArgument<string>("DisplayName");

            _diagnosticMessageSink = diagnosticMessageSink;
            DisplayName = suppliedDisplayName ?? BaseDisplayName;
            Variation = variation;
            Iterations = iterations;
            WarmupIterations = warmupIterations;

            var methodArguments = new List<object> { MetricCollector };
            if (testMethodArguments != null)
            {
                methodArguments.AddRange(testMethodArguments);
            }

            TestMethodArguments = methodArguments.ToArray();
        }
예제 #26
0
 protected override void RunTestCases(IEnumerable<IXunitTestCase> testCases, IMessageSink messageSink, ITestFrameworkOptions executionOptions)
 {
     var cases = testCases.Where(t =>
         t.Class.GetCustomAttributes(typeof(RunIfConfiguredAttribute)) == null
         || TestConfig.Instance.IsConfigured);
     base.RunTestCases(cases, messageSink, executionOptions);
 }
 public ScenarioOutlineRunner(
     IMessageSink diagnosticMessageSink,
     IXunitTestCase scenarioOutline,
     string displayName,
     string skipReason,
     object[] constructorArguments,
     IMessageBus messageBus,
     ExceptionAggregator aggregator,
     CancellationTokenSource cancellationTokenSource)
     : base(
         scenarioOutline,
         displayName,
         skipReason,
         constructorArguments,
         noArguments,
         messageBus,
         aggregator,
         cancellationTokenSource)
 {
     this.diagnosticMessageSink = diagnosticMessageSink;
     this.scenarioRunnerFactory = new ScenarioRunnerFactory(
         this.TestCase,
         this.DisplayName,
         this.MessageBus,
         this.TestClass,
         this.ConstructorArguments,
         this.SkipReason,
         this.BeforeAfterAttributes,
         this.Aggregator,
         this.CancellationTokenSource);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionPerAssemblyTestCollectionFactory" /> class.
        /// </summary>
        /// <param name="testAssembly">The assembly.</param>
        /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
        public CollectionPerAssemblyTestCollectionFactory(ITestAssembly testAssembly, IMessageSink diagnosticMessageSink)
        {
            this.testAssembly = testAssembly;

            defaultCollection = new TestCollection(testAssembly, null, "Test collection for " + Path.GetFileName(testAssembly.Assembly.AssemblyPath));
            collectionDefinitions = TestCollectionFactoryHelper.GetTestCollectionDefinitions(testAssembly.Assembly, diagnosticMessageSink);
        }
 internal static IMessageCtrl DoAsyncDispatch(IMessage reqMsg, IMessageSink replySink)
 {
     object[] args = new object[4];
     ServerIdentity serverIdentity = InternalSink.GetServerIdentity(reqMsg);
     if (RemotingServices.CORProfilerTrackRemotingAsync())
     {
         Guid empty = Guid.Empty;
         if (RemotingServices.CORProfilerTrackRemotingCookie())
         {
             object obj2 = reqMsg.Properties["CORProfilerCookie"];
             if (obj2 != null)
             {
                 empty = (Guid) obj2;
             }
         }
         RemotingServices.CORProfilerRemotingServerReceivingMessage(empty, true);
         if (replySink != null)
         {
             IMessageSink sink = new ServerAsyncReplyTerminatorSink(replySink);
             replySink = sink;
         }
     }
     Context serverContext = serverIdentity.ServerContext;
     args[0] = reqMsg;
     args[1] = replySink;
     args[2] = Thread.CurrentContext;
     args[3] = serverContext;
     InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(CrossContextChannel.DoAsyncDispatchCallback);
     return (IMessageCtrl) Thread.CurrentThread.InternalCrossContextCallback(serverContext, ftnToCall, args);
 }
예제 #30
0
파일: WcfTestCase.cs 프로젝트: roncain/wcf
 internal WcfTestCase(IXunitTestCase testCase, string skippedReason = null, bool isTheory = false, IMessageSink diagnosticMessageSink = null)
 {
     _testCase = testCase;
     _skippedReason = skippedReason;
     _isTheory = isTheory;
     _diagnosticMessageSink = diagnosticMessageSink;
 }
예제 #31
0
 public static LNode ParseTokenTree(TokenTree tokens, IMessageSink sink)
 {
     return(StageOneParser.Parse(tokens, tokens.File, sink));
 }
 IMessageSink IContributeServerContextSink.GetServerContextSink(IMessageSink next)
 {
     CallSeq.Add("IContributeServerContextSink(" + id + ").GetServerContextSink");
     return(new GenericMessageSink(null, next, "ServerContextSink(" + id + ")"));
 }
 IMessageSink IContributeObjectSink.GetObjectSink(MarshalByRefObject o, IMessageSink next)
 {
     CallSeq.Add("IContributeObjectSink(" + id + ").GetObjectSink");
     return(new GenericMessageSink(o, next, "ObjectSink(" + id + ")"));
 }
 public GenericMessageSink(MarshalByRefObject obj, IMessageSink nextSink, string type)
 {
     _type = type;
     _next = nextSink;
 }
 public SharedHomeDirectory(IMessageSink messageSink)
 {
     Log = new SharedTestOutputHelper(messageSink);
     Initialize();
 }
 public SpecFlowTestFramework(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
 {
 }
예제 #37
0
 internal StageOneParser(IList <Token> tokens, ISourceFile file, IMessageSink messageSink)
     : base(ReclassifyTokens(tokens), default(Token), file)
 {
     ErrorSink = messageSink;
 }
 public IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
 {
     throw new NotSupportedException();
 }
 public SkippableFactDiscoverer(IMessageSink diagnosticMessageSink)
     : base(diagnosticMessageSink)
 {
     _diagnosticMessageSink = diagnosticMessageSink;
 }
 public ClientChannelSinkStack(IMessageSink replySink)
 {
     this._replySink = replySink;
 }
예제 #41
0
 public MessageSinkLogger(IMessageSink messageSink)
 {
     this.messageSink = messageSink;
 }
 public ContextRestoreSink(IMessageSink next, Context context, IMessage call)
 {
     this._next    = next;
     this._context = context;
     this._call    = call;
 }
예제 #43
0
 public FusonicTestAssemblyRunner(ITestAssembly testAssembly, IEnumerable <IXunitTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions) : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
 {
 }
        /// <inheritdoc cref="XunitTestCase"/>
        /// <remarks>
        /// This method is called by the xUnit test framework classes to run the test case. We will do the
        /// loop here, forwarding on to the implementation in XunitTestCase to do the heavy lifting.We will
        /// continue to re-run the test until the aggregator has an error(meaning that some internal error
        /// condition happened), or the test runs without failure, or we've hit the maximum number of tries.
        /// </remarks>
        public override async Task <RunSummary> RunAsync(
            IMessageSink diagnosticMessageSink,
            IMessageBus messageBus,
            object[] constructorArguments,
            ExceptionAggregator aggregator,
            CancellationTokenSource cancellationTokenSource
            )
        {
            int runCount = 0;

            while (true)
            {
                // This is really the only tricky bit: we need to capture and delay messages (since those will
                // contain run status) until we know we've decided to accept the final result;
                var delayedMessageBus = new DelayedMessageBus(messageBus);

                string testName = DisplayName;
                if (runCount > 0)
                {
                    testName += $"\n\nRETRY:{runCount}";
                }

                // Do not throw any exceptions here if can't send test case notification because
                // xunit do not expects any exceptions here and so it crashes the process.
                // Notification sending fails probably because of rate limiting by Telegram.
                for (int i = 0; i < 2; i++)
                {
                    try
                    {
                        await TestsFixture.Instance.SendTestCaseNotificationAsync(testName);

                        break;
                    }
                    catch (Exception)
                    {
                        // Log any exceptions here so we could at least know if notification
                        // sending failed
                        var waitTimeout = 30;
                        var message     = new DiagnosticMessage(
                            "Couldn't send test name notification for test '{0}', " +
                            "will try one more in {1} seconds.",
                            DisplayName,
                            waitTimeout
                            );
                        diagnosticMessageSink.OnMessage(message);
                        await Task.Delay(TimeSpan.FromSeconds(waitTimeout));
                    }
                }

                // await Policy
                //     .Handle<TaskCanceledException>()
                //     .Or<HttpRequestException>()
                //     .Or<ApiRequestException>()
                //     .WaitAndRetry(1, i => TimeSpan.FromSeconds(30))
                //     .Execute(() =>
                //         TestsFixture.Instance.SendTestCaseNotificationAsync(testName)
                //     );

                var summary = await base.RunAsync(
                    diagnosticMessageSink,
                    delayedMessageBus,
                    constructorArguments,
                    aggregator,
                    cancellationTokenSource
                    );

                runCount += 1;

                var testRunHasUnexpectedErrors = aggregator.HasExceptions ||
                                                 summary.Failed == 0;

                var retryExceeded = runCount > _maxRetries;

                var testRunHasExpectedException = summary.Failed == 1 &&
                                                  !delayedMessageBus
                                                  .ContainsException(_exceptionTypeFullName);

                var testCaseRunShouldReturn = testRunHasUnexpectedErrors ||
                                              retryExceeded ||
                                              testRunHasExpectedException;

                if (testCaseRunShouldReturn)
                {
                    delayedMessageBus.Dispose(); // Sends all the delayed messages
                    return(summary);
                }

                diagnosticMessageSink.OnMessage(new DiagnosticMessage(
                                                    "Execution of '{0}' failed (attempt #{1}), retrying in {2} seconds...",
                                                    DisplayName,
                                                    runCount,
                                                    _delaySeconds
                                                    ));

                await Task.Delay(_delaySeconds * 1_000);
            }
        }
예제 #45
0
 public SkippableFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
 }
예제 #46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StaFactDiscoverer"/> class.
 /// </summary>
 /// <param name="diagnosticMessageSink">The diagnostic message sink.</param>
 public StaFactDiscoverer(IMessageSink diagnosticMessageSink)
     : base(diagnosticMessageSink)
 {
     this.diagnosticMessageSink = diagnosticMessageSink;
 }
예제 #47
0
 public SkippedTestCase(string skipReason, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, object[] testMethodArguments = null)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments)
 {
     _skipReason = skipReason;
 }
 public ConditionalFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
 {
 }
예제 #49
0
 public InterceptSink(MarshalByRefObject interceptedObject, IMessageSink nextSink)
 {
     m_NextSink          = nextSink;
     m_InterceptedObject = interceptedObject;
     m_WeaveManager      = WeaveManagerFactory.Create();
 }
예제 #50
0
        public virtual IMessageCtrl AsyncProcessMessage(IMessage msg, IMessageSink replySink)
        {
            IMethodCallMessage mcm1        = (IMethodCallMessage)msg;
            IMessageCtrl       messageCtrl = (IMessageCtrl)null;
            IMessage           msg1        = (IMessage)null;
            LogicalCallContext callCtx1    = (LogicalCallContext)null;
            bool flag = false;

            try
            {
                try
                {
                    LogicalCallContext logicalCallContext1 = (LogicalCallContext)mcm1.Properties[(object)Message.CallContextKey];
                    object             server = this._server;
                    StackBuilderSink.VerifyIsOkToCallMethod(server, (IMethodMessage)mcm1);
                    callCtx1 = CallContext.SetLogicalCallContext(logicalCallContext1);
                    flag     = true;
                    IMessage msg2 = msg;
                    logicalCallContext1.PropagateIncomingHeadersToCallContext(msg2);
                    LogicalCallContext threadCallContext = callCtx1;
                    StackBuilderSink.PreserveThreadPrincipalIfNecessary(logicalCallContext1, threadCallContext);
                    ServerChannelSinkStack channelSinkStack = msg.Properties[(object)"__SinkStack"] as ServerChannelSinkStack;
                    if (channelSinkStack != null)
                    {
                        channelSinkStack.ServerObject = server;
                    }
                    MethodBase methodBase = StackBuilderSink.GetMethodBase((IMethodMessage)mcm1);
                    object[]   outArgs1   = (object[])null;
                    RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(methodBase);
                    object[] args = Message.CoerceArgs((IMethodMessage)mcm1, reflectionCachedData.Parameters);
                    object   obj  = this.PrivateProcessMessage(methodBase.MethodHandle, args, server, out outArgs1);
                    this.CopyNonByrefOutArgsFromOriginalArgs(reflectionCachedData, args, ref outArgs1);
                    if (replySink != null)
                    {
                        LogicalCallContext logicalCallContext2 = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
                        if (logicalCallContext2 != null)
                        {
                            logicalCallContext2.RemovePrincipalIfNotSerializable();
                        }
                        object             ret          = obj;
                        object[]           outArgs2     = outArgs1;
                        int                outArgsCount = outArgs2 == null ? 0 : outArgs1.Length;
                        LogicalCallContext callCtx2     = logicalCallContext2;
                        IMethodCallMessage mcm2         = mcm1;
                        msg1 = (IMessage) new ReturnMessage(ret, outArgs2, outArgsCount, callCtx2, mcm2);
                        logicalCallContext2.PropagateOutgoingHeadersToMessage(msg1);
                    }
                }
                catch (Exception ex)
                {
                    if (replySink != null)
                    {
                        msg1 = (IMessage) new ReturnMessage(ex, mcm1);
                        ((ReturnMessage)msg1).SetLogicalCallContext((LogicalCallContext)mcm1.Properties[(object)Message.CallContextKey]);
                    }
                }
                finally
                {
                    if (replySink != null)
                    {
                        replySink.SyncProcessMessage(msg1);
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    CallContext.SetLogicalCallContext(callCtx1);
                }
            }
            return(messageCtrl);
        }
예제 #51
0
 public TheoryDiscoverer(IMessageSink diagnosticMessageSink)
 {
     _diagnosticMessageSink = diagnosticMessageSink;
 }
 public SkipOnAppVeyorTestDiscoverer(IMessageSink diagnosticMessageSink)
 {
     _diagnosticMessageSink = diagnosticMessageSink;
 }
예제 #53
0
 public void OnConnected(IMessageSink sink)
 {
     Sink = sink;
     _onConnectedEvent.Set();
 }
예제 #54
0
 public AssemblyRunner(ITestAssembly testAssembly, IEnumerable <IXunitTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions, XunitTestEnvironment testEnvironment)
     : base(testAssembly, testCases, diagnosticMessageSink, executionMessageSink, executionOptions)
 {
     _testEnvironment = testEnvironment;
 }
예제 #55
0
 public SkippableTheoryTestCase(IMessageSink diagnosticMessageSink, Xunit.Sdk.TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod)
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod)
 {
 }
예제 #56
0
 public NLogThrowExceptionsDefault(IMessageSink messageSink)
     : base(messageSink)
 {
     // Place initialization code here
 }
예제 #57
0
 /// <summary>
 /// Microsoft ILogger implementation, which can be used in XUnit tests as stub for real logger.
 /// Writes messages to Output stream and also stores in internal property <seealso cref="LoggedMessages" /> so they can be asserted.
 /// </summary>
 /// <param name="output">Accepting MessageSink as output from Fixtures.</param>
 public XUnitLogger(IMessageSink output) => _messageSink = output;
예제 #58
0
 public SkippableFactDiscoverer(IMessageSink diagnosticMessageSink)
 {
     this.diagnosticMessageSink = diagnosticMessageSink;
 }
 public TestFrameworkExecutor(AssemblyName assemblyName, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
     : base(assemblyName, sourceInformationProvider, diagnosticMessageSink)
 {
 }
 internal RetryHttpMessageHandler(int retryCount, IMessageSink diagnosticMessageSink)
 {
     _retryCount            = retryCount;
     _diagnosticMessageSink = diagnosticMessageSink;
 }