protected virtual void PresentTest(CSUnitTestElement value, IPresentableItem item, TreeModelNode modelNode, PresentationState state) { item.Clear(); if (value.Fixture.GetTypeClrName() != value.GetTypeClrName()) { item.RichText = string.Format("{0}.{1}", new CLRTypeName(value.GetTypeClrName()).ShortName, value.MethodName); } else { item.RichText = value.MethodName; } if (value.IsExplicit) { item.RichText.SetForeColor(SystemColors.GrayText); } Image typeImage = UnitTestManager.GetStandardImage(UnitTestElementImage.Test); Image stateImage = UnitTestManager.GetStateImage(state); if (stateImage != null) { item.Images.Add(stateImage); } else if (typeImage != null) { item.Images.Add(typeImage); } }
public FileExplorer(MSpecUnitTestProvider provider, ElementFactories factories, IFile file, UnitTestElementLocationConsumer consumer, CheckForInterrupt interrupted) { if (file == null) { throw new ArgumentNullException("file"); } if (provider == null) { throw new ArgumentNullException("provider"); } _consumer = consumer; _file = file; _interrupted = interrupted; var project = file.GetSourceFile().ToProjectFile().GetProject(); #if !RESHARPER_8 _assemblyPath = UnitTestManager.GetOutputAssemblyPath(project).FullPath; #else _assemblyPath = project.GetOutputFilePath().FullPath; #endif _elementHandlers = new List <IElementHandler> { new ContextElementHandler(factories), new ContextSpecificationElementHandler(factories), new BehaviorElementHandler(factories) }; }
public static void AddSilverlightUnitTestTask(this IList<UnitTestTask> sequence, PlatformID silverlightPlatform, UnitTestManager manager) { var provider = manager.GetProvider(SilverlightUnitTestProvider.RunnerId); var element = new SilverlightUnitTestElement(provider); var remoteTask = new SilverlightUnitTestTask(silverlightPlatform.Version); sequence.Insert(0, new UnitTestTask(element, remoteTask)); }
protected virtual void PresentTestFixture(CSUnitTestFixtureElement value, IPresentableItem item, TreeModelNode modelNode, PresentationState state) { item.Clear(); if (IsNodeParentNatural(modelNode, value)) { item.RichText = new CLRTypeName(value.GetTypeClrName()).ShortName; } else { var name = new CLRTypeName(value.GetTypeClrName()); if (string.IsNullOrEmpty(name.NamespaceName)) { item.RichText = string.Format("{0}", name.ShortName); } else { item.RichText = string.Format("{0}.{1}", name.NamespaceName, name.ShortName); } } Image typeImage = UnitTestManager.GetStandardImage(UnitTestElementImage.TestContainer); Image stateImage = UnitTestManager.GetStateImage(state); if (stateImage != null) { item.Images.Add(stateImage); } else if (typeImage != null) { item.Images.Add(typeImage); } AppendOccurencesCount(item, modelNode, "test"); }
private ITestDriver CreateTestDriver() { var excludedTestFrameworkIds = new List <string>(); #if RESHARPER_60 var unitTestManager = UnitTestManager.GetInstance(provider.Solution); var unitTestProviders = unitTestManager.GetEnabledProviders(); #else var unitTestProviders = provider.UnitTestProvidersManager.GetEnabledProviders(); #endif foreach (var testProvider in unitTestProviders) { IList <string> frameworkIds; if (IncompatibleProviders.TryGetValue(testProvider.ID, out frameworkIds)) { excludedTestFrameworkIds.AddRange(frameworkIds); } } var testFrameworkSelector = new TestFrameworkSelector { Filter = testFrameworkHandle => !excludedTestFrameworkIds.Contains(testFrameworkHandle.Id), FallbackMode = TestFrameworkFallbackMode.Approximate }; return(testFrameworkManager.GetTestDriver(testFrameworkSelector, logger)); }
static void Main(string[] args) { UnitTestManager unitTestManager = new UnitTestManager(); unitTestManager.ExecuteAllUnitTests(new DisplayTestResults(PrintResults)); Console.ReadKey(); }
public FileExplorer(IUnitTestProvider provider, UnitTestElementLocationConsumer consumer, IFile file, CheckForInterrupt interrupted) { if (file == null) { throw new ArgumentNullException("file"); } if (provider == null) { throw new ArgumentNullException("provider"); } _consumer = consumer; _file = file; _interrupted = interrupted; IProject project = file.ProjectFile.GetProject(); string assemblyPath = UnitTestManager.GetOutputAssemblyPath(project).FullPath; var cache = new ContextCache(); var contextFactory = new ContextFactory(provider, project, assemblyPath, cache); var contextSpecificationFactory = new ContextSpecificationFactory(provider, project, cache); var behaviorFactory = new BehaviorFactory(provider, project, cache); var behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider, project); _elementHandlers = new List <IElementHandler> { new ContextElementHandler(contextFactory), new ContextSpecificationElementHandler(contextSpecificationFactory), new BehaviorElementHandler(behaviorFactory, behaviorSpecificationFactory) }; }
public void TestMethod1() { MyClass.Buffer = new StringBuilder(); UnitTestManager.Call(() => new Test().Hello()); var txt = MyClass.Buffer.ToString(); Assert.AreEqual("OnReady,OnApiCreated,OnPropertiesParsed,OnArgumentsParsed,OnEnding,", txt); }
public static void AddSilverlightUnitTestTask(this IList<UnitTestTask> sequence, IProject silverlightProject, UnitTestManager manager) { var provider = manager.GetProvider(SilverlightUnitTestProvider.RunnerId); var element = new SilverlightUnitTestElement(provider); var remoteTask = new SilverlightUnitTestTask(silverlightProject.PlatformID.Version, silverlightProject.GetXapPath(), silverlightProject.GetDllPath()); sequence.Insert(0, new UnitTestTask(element, remoteTask)); }
static void Main(string[] args) { UnitTestManager unitTestManager = new UnitTestManager(); unitTestManager.ExecuteAllUnitTests(new DisplayTestResults(PrintResults)); Console.ReadKey(); }
private static void CreateSilverlightSequence(IList<UnitTestTask> sequence, IUnitTestLaunch launch, UnitTestManager manager, IProject silverlightProject) { var silverlightRun = launch.GetOrCreateSilverlightRun(silverlightProject.PlatformID); sequence.AddSilverlightUnitTestTask(silverlightProject, manager); sequence.RemoveAssemblyLoadTasks(); silverlightRun.AddTaskSequence(sequence); }
public void HelloAsyncTest() { var r = UnitTestManager.Call(() => new Test().HelloAsync()); if (r.Exception != null) { throw r.Exception; } Assert.AreEqual("Hello", r.Result); }
public SilverlightXunitTestFileExplorer(ISolution solution) { provider = UnitTestManager.GetInstance(solution).GetProvider(ProviderId); if (provider == null) { xUnitInstalled = false; provider = UnitTestManager.GetInstance(solution).GetProvider(SilverlightUnitTestProvider.RunnerId); } }
public FileExplorer(MSpecUnitTestProvider provider, #if RESHARPER_61 IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager, #endif UnitTestElementLocationConsumer consumer, IFile file, CheckForInterrupt interrupted) { if (file == null) { throw new ArgumentNullException("file"); } if (provider == null) { throw new ArgumentNullException("provider"); } _consumer = consumer; _file = file; _interrupted = interrupted; #if RESHARPER_6 IProject project = file.GetSourceFile().ToProjectFile().GetProject(); #else IProject project = file.ProjectFile.GetProject(); #endif var projectEnvoy = new ProjectModelElementEnvoy(project); string assemblyPath = UnitTestManager.GetOutputAssemblyPath(project).FullPath; var cache = new ContextCache(); #if RESHARPER_61 var contextFactory = new ContextFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, assemblyPath, cache); var contextSpecificationFactory = new ContextSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache); var behaviorFactory = new BehaviorFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy, cache); var behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider, manager, psiModuleManager, cacheManager, project, projectEnvoy); #else var contextFactory = new ContextFactory(provider, project, projectEnvoy, assemblyPath, cache); var contextSpecificationFactory = new ContextSpecificationFactory(provider, project, projectEnvoy, cache); var behaviorFactory = new BehaviorFactory(provider, project, projectEnvoy, cache); var behaviorSpecificationFactory = new BehaviorSpecificationFactory(provider, project, projectEnvoy); #endif _elementHandlers = new List <IElementHandler> { new ContextElementHandler(contextFactory), new ContextSpecificationElementHandler(contextSpecificationFactory), new BehaviorElementHandler(behaviorFactory, behaviorSpecificationFactory) }; }
private static void ConvertToSilverlightSequenceIfNecessary(IList<UnitTestTask> sequence, UnitTestRun run, IUnitTestLaunch launch, UnitTestManager manager) { if (!sequence.IsSilverlightSequence()) { var silverlightProject = sequence.GetSilverlightProject(); if (silverlightProject != null) { run.GetSequences().Remove(sequence); CreateSilverlightSequence(sequence, launch, manager, silverlightProject); } } }
private static void ConvertToSilverlightSequenceIfNecessary(IList<UnitTestTask> sequence, UnitTestRun run, IUnitTestLaunch launch, UnitTestManager manager) { if (!sequence.IsSilverlightSequence()) { var requiredSilverlightPlatform = sequence.GetRequiredSilverlightPlatform(); if (requiredSilverlightPlatform != null) { run.GetSequences().Remove(sequence); CreateSilverlightSequence(sequence, launch, manager, requiredSilverlightPlatform); } } }
static void SetImage(IPresentableItem item, PresentationState state, UnitTestElementImage imageType) { Image stateImage = UnitTestManager.GetStateImage(state); Image typeImage = UnitTestManager.GetStandardImage(imageType); if (stateImage != null) { item.Images.Add(stateImage); } else if (typeImage != null) { item.Images.Add(typeImage); } }
public static void EnsureSilverlightPlatformSupport(this IUnitTestLaunch launch, UnitTestManager manager) { var runs = launch.GetRuns(); foreach (var run in runs.Values.ToArray()) { foreach (var sequence in run.GetSequences().ToArray()) { ConvertToSilverlightSequenceIfNecessary(sequence, run, launch, manager); } } launch.RemoveEmptyRuns(); }
private void PresentTestElement(GallioTestElement value, IPresentableItem item, TreeModelNode modelNode, PresentationState state) { item.Clear(); item.RichText = value.TestName; #if RESHARPER_60_OR_NEWER if (value.Explicit) { item.RichText.SetForeColor(SystemColors.GrayText); } var typeImage = UnitTestIconManager.GetStandardImage(UnitTestElementImage.Test); var stateImage = UnitTestIconManager.GetStateImage(state); if (stateImage != null) { item.Images.Add(stateImage); } else if (typeImage != null) { item.Images.Add(typeImage); } #else if (value.IsExplicit) { item.RichText.SetForeColor(SystemColors.GrayText); } Image image = UnitTestManager.GetStateImage(state); if (image == null) { image = UnitTestManager.GetStandardImage(value.IsTestCase ? UnitTestElementImage.Test : UnitTestElementImage.TestCategory); } if (image != null) { item.Images.Add(image); } if (!value.IsTestCase) { AppendOccurencesCount(item, modelNode, "test"); } #endif }
public MyFileExplorer(IUnitTestProvider provider, UnitTestElementLocationConsumer consumer, IFile file, CheckForInterrupt interrupted) { if (file == null) { throw new ArgumentNullException("file"); } if (provider == null) { throw new ArgumentNullException("provider"); } myConsumer = consumer; myProvider = provider; myFile = file; myInterrupted = interrupted; myProject = myFile.ProjectFile.GetProject(); myAssemblyPath = UnitTestManager.GetOutputAssemblyPath(myProject).FullPath; }
private ITestDriver CreateTestDriver() { var excludedTestFrameworkIds = new List <string>(); foreach (IUnitTestProvider provider in UnitTestManager.GetInstance(SolutionManager.Instance.CurrentSolution).GetEnabledProviders()) { IList <string> frameworkIds; if (IncompatibleProviders.TryGetValue(provider.ID, out frameworkIds)) { excludedTestFrameworkIds.AddRange(frameworkIds); } } var testFrameworkSelector = new TestFrameworkSelector() { Filter = testFrameworkHandle => !excludedTestFrameworkIds.Contains(testFrameworkHandle.Id), FallbackMode = TestFrameworkFallbackMode.Approximate }; return(testFrameworkManager.GetTestDriver(testFrameworkSelector, logger)); }
public void CheckPropAsyncTest() { var r = UnitTestManager.Call(() => new Test() { Name = "abc" }.CheckPropAsync("abc")); if (r.Exception != null) { throw r.Exception; } var r2 = UnitTestManager.Call(() => new Test() { Name = "abc1" }.CheckPropAsync("abc")); if (r2.Exception == null) { Assert.Fail(); } }
protected void btnSubmitTests_Click(object sender, EventArgs e) { UnitTestManager manager = new UnitTestManager(this); IEnumerable <ListItem> selectedCats = cblCategories.Items.Cast <ListItem>().Where(a => a.Selected); //build dictionary with any methods with the selected categories Dictionary <string, TestMethod> sets = new Dictionary <string, TestMethod>(); if (selectedCats.Any()) { foreach (ListItem li in selectedCats) { foreach (TestFixture tf in Fixtures) { bool fixtHasCat = (tf.Categories().Any(b => b.Equals(li.Value))); foreach (TestMethod tm in tf.Tests) { //don't add twice and if fixture or the method has the selected category then add if (!sets.ContainsKey(tm.MethodName) && (fixtHasCat || tm.Categories().Any(b => b.Equals(li.Value)))) { sets.Add(tm.MethodName, tm); } } } } } else // add all { sets = suite.GetMethods().ToDictionary(a => a.MethodName); } //run all tests found foreach (TestMethod method in sets.Values) { manager.RunTest(method); } }
public void Present(UnitTestElement element, IPresentableItem item, TreeModelNode node, PresentationState state) { var testElement = element as StorEvilUnitTestElement; if (testElement == null) { return; } item.RichText = element.ShortName; Image standardImage = UnitTestManager.GetStandardImage(UnitTestElementImage.Test); Image stateImage = UnitTestManager.GetStateImage(state); if (stateImage != null) { item.Images.Add(stateImage); } else if (standardImage != null) { item.Images.Add(standardImage); } }
public static string GetDllPath(this IProject silverlightProject) { return(UnitTestManager.GetOutputAssemblyPath(silverlightProject).FullPath); }
public static void EnsureSilverlightPlatformSupport(this IUnitTestLaunch launch, UnitTestManager manager) { var runs = launch.GetRuns(); foreach (var run in runs.Values.ToArray()) { foreach (var sequence in run.GetSequences().ToArray()) { ConvertToSilverlightSequenceIfNecessary(sequence, run, launch, manager); } } launch.RemoveEmptyRuns(); }
private static void ConvertToSilverlightSequenceIfNecessary(IList <UnitTestTask> sequence, UnitTestRun run, IUnitTestLaunch launch, UnitTestManager manager) { if (!sequence.IsSilverlightSequence()) { var silverlightProject = sequence.GetSilverlightProject(); if (silverlightProject != null) { run.GetSequences().Remove(sequence); CreateSilverlightSequence(sequence, launch, manager, silverlightProject); } } }
public void NotApiTest() { var r = UnitTestManager.Call(() => new Test().NotApi()); Assert.IsInstanceOfType(r.Exception, typeof(ApiNotFoundException)); }
private static void CreateSilverlightSequence(IList <UnitTestTask> sequence, IUnitTestLaunch launch, UnitTestManager manager, IProject silverlightProject) { var silverlightRun = launch.GetOrCreateSilverlightRun(silverlightProject.PlatformID); sequence.AddSilverlightUnitTestTask(silverlightProject, manager); sequence.RemoveAssemblyLoadTasks(); silverlightRun.AddTaskSequence(sequence); }
public ExtendedDebugTaskRunnerHostController(UnitTestManager manager, UnitTestSessionManager sessionManager, util::JetBrains.Util.Lazy.Lazy <IVsDebugger2> debugger2, DTE dte, IThreading threading, IUnitTestLaunch launch, string remotingAddress) : base(manager, sessionManager, debugger2, dte, threading, launch, remotingAddress) { }
public ExtendedDebugTaskRunnerHostController(UnitTestManager manager, UnitTestSessionManager sessionManager, util::JetBrains.Util.Lazy.Lazy<IVsDebugger2> debugger2, DTE dte, IThreading threading, IUnitTestLaunch launch, string remotingAddress) : base(manager, sessionManager, debugger2, dte, threading, launch, remotingAddress) { }
static void RunUnitTest(string[] args) { //params 1 = test assembly string testAssembly = string.Empty; if (args.Length > 1) { testAssembly = args[1]; } else { Console.WriteLine("You need to specify an assembly."); return; } //params 2 = test category List <string> categories = new List <string>(); if (args.Length > 2) { foreach (string s in GetStrings(args[2])) { if (!categories.Contains(s)) { Console.WriteLine(string.Format("Caught '{0}' Category.", s)); categories.Add(s); } } } //params 3 = test method List <string> names = new List <string>(); if (args.Length > 3) { foreach (string n in GetStrings(args[3])) { if (!names.Contains(n)) { Console.WriteLine(string.Format("Caught '{0}' Method.", n)); names.Add(n); } } } //setup for testing CoreExtensions.Host.InitializeService(); //get the test suite TestSuite suite = TestUtility.GetTestSuite(testAssembly); Dictionary <string, TestMethod> Methods = new Dictionary <string, TestMethod>(); IEnumerable <TestMethod> allMethods = suite.GetMethods(); if (!categories.Any() && !names.Any()) // if nothing selected add all { Methods = allMethods.ToDictionary(a => a.MethodName); } else // add one at a time { IEnumerable <TestFixture> Fixtures = suite.GetFixtures(); foreach (string c in categories) { foreach (TestFixture tf in Fixtures) { bool fixtHasCat = (tf.Categories().Any(b => b.Equals(c))); foreach (TestMethod tm in tf.Tests) { //if fixture or the method has the selected category then add if (fixtHasCat || tm.Categories().Any(b => b.Equals(c))) { Console.WriteLine(string.Format("Adding '{0}' Method.", tm.MethodName)); Methods.Add(tm.MethodName, tm); } } } } foreach (string n in names) { foreach (TestMethod ctm in allMethods.Where(a => a.MethodName.Equals(n))) { if (!Methods.ContainsKey(ctm.MethodName)) { Console.WriteLine(string.Format("Adding '{0}' Method.", ctm.MethodName)); Methods.Add(ctm.MethodName, ctm); } } } } if (!Methods.Any()) { Console.WriteLine("There are no Test Methods found. Make sure the class method has the [Test] attribute."); return; } UnitTestManager manager = new UnitTestManager(new UnitConsoleTestHandler()); foreach (TestMethod tm in Methods.Values) { manager.RunTest(tm); } }
public static void AddSilverlightUnitTestTask(this IList <UnitTestTask> sequence, IProject silverlightProject, UnitTestManager manager) { var provider = manager.GetProvider(SilverlightUnitTestProvider.RunnerId); var element = new SilverlightUnitTestElement(provider); var remoteTask = new SilverlightUnitTestTask(silverlightProject.PlatformID.Version, silverlightProject.GetXapPath(), silverlightProject.GetDllPath()); sequence.Insert(0, new UnitTestTask(element, remoteTask)); }
protected override ITaskRunnerHostController CreateWrappedHostController(UnitTestManager manager, UnitTestSessionManager sessionManager, IUnitTestLaunch launch, string remotingAddress) { return(new ExtendedDebugTaskRunnerHostController(manager, sessionManager, debugger2, dte, threading, launch, remotingAddress)); }
public ITaskRunnerHostController CreateHostController(UnitTestManager manager, UnitTestSessionManager sessionManager, IUnitTestLaunch launch, string remotingAddress) { launch.EnsureSilverlightPlatformSupport(manager); return(CreateWrappedHostController(manager, sessionManager, launch, remotingAddress)); }
private void OnEnable() { unitTestManager = new UnitTestManager(); }
protected virtual ITaskRunnerHostController CreateWrappedHostController(UnitTestManager manager, UnitTestSessionManager sessionManager, IUnitTestLaunch launch, string remotingAddress) { return(WrappedHostProvider.CreateHostController(manager, sessionManager, launch, remotingAddress)); }