-
-
Save ylelan/a8af8e1816675d181d959de73822f1a0 to your computer and use it in GitHub Desktop.
Same as amirrajan, working on .net core 2.0 on ubuntu machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Reflection; | |
using NSpec; | |
using System.IO; | |
using NSpec.Api; | |
using NSpec.Domain; // SpecFinder | |
using NSpec.Domain.Formatters; // ConsoleFormatter | |
namespace Calculator.specs | |
{ | |
class Program | |
{ | |
/* | |
* Original version, from NSpec documentation, or Gist example: | |
var types = GetType().GetTypeInfo().Assembly.GetTypes(); | |
* leads to: | |
Program.cs(17,21): error CS0120: An object reference is required for | |
the nonstatic field, method, or property 'member' | |
'object.GetType()' [./Calculator/specs/specs.csproj] | |
*/ | |
static void Main(string[] args) | |
{ | |
var types = typeof(Program).Assembly.GetTypes(); | |
var finder = new SpecFinder(types, ""); | |
var tagsFilter = new Tags().Parse(""); | |
var builder = new ContextBuilder(finder, tagsFilter, new DefaultConventions()); | |
var runner = new ContextRunner(tagsFilter, new ConsoleFormatter(), false); | |
var results = runner.Run(builder.Contexts().Build()); | |
if(results.Failures().Count() > 0) | |
{ | |
Environment.Exit(1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment