public SampleComponentTests(ITestOutputHelper testOutputHelper, ComponentTestPlatform componentTestPlatform) { // logged messagees appear in the detail pane of Rider's test runner for // Running a successful test // Debugging a successful test // Running a failed test // Debugging a failed test // logger under for Run and Debug // I want to get hold of the xunit test results when running from the command line. // "dotnet test" isn't providing them as far as I can see from my limited investigations // Even after specifying RuntimeFramework as 2.1.4 in the csproj I got // "dotnet xunit" should be more fruitful but fails with the following issue: // Could not load file or assembly 'Microsoft.Extensions.Options, Version=2.1.0.0, // There is a nuget package for M.E.O 2.1.1 but the install fails and is rolled back // There are no other v2 nuget packages except a preview 2.2. // "dotnet xunit" seems to be a no-go - did not investigate whether it solved // the original problem of locating and using test results. // // It turns out that the following is not a bad start: // "dotnet test --logger trx;LogfileName=test_results.xml --results-directory ./test_results" // test_results.xml will appear in <proj>/source/DasBlog.Tests/FunctionalTests/test_results componentTestPlatform.CompleteSetup(testOutputHelper); this.platform = componentTestPlatform; this.testOutputHelper = testOutputHelper; dasBlogSandbox = platform.CreateSandbox(Constants.VanillaEnvironment); // dasBlogSandbox.Init(); }
GetOptions(IDasBlogSandbox sandbox) { var configuration = GetDasBlogAppConfiguration(sandbox); return(new OptionsWrapper <SiteConfig>(new OptionsBuilder <SiteConfig>().Build(configuration)) , new OptionsWrapper <MetaTags>(new OptionsBuilder <MetaTags>().Build(configuration))); }
private IOptions <BlogManagerOptions> BuildBlogManagerOptions(IDasBlogSandbox sandbox) { var configuration = GetDasBlogAppConfiguration(sandbox); return(new OptionsWrapper <BlogManagerOptions>( new OptionsBuilder <BlogManagerOptions>().Build(configuration))); }
private IDasBlogSettings CreateDasBlogSettings(IDasBlogSandbox sandbox) { (var siteConfigAccessor, var metaTagsAccessor) = GetOptions(sandbox); var dasBlogSettings = new DasBlogSettings( new HostingEnvironmentTest(sandbox.TestEnvironmentPath) , siteConfigAccessor , metaTagsAccessor , new SiteSecurityConfig() , null); return(dasBlogSettings); }
/// <summary> /// returns a fully functional blog manager object pointed at the environment provided /// </summary> /// <param name="environment">e.g. "Vanilla"</param> /// <returns>ready for anything</returns> public BlogManager CreateBlogManager(IDasBlogSandbox sandbox) { var dasBlogSettings = CreateDasBlogSettings(sandbox); ILogger <BlogManager> logger = ServiceProvider.GetService <ILoggerFactory>().CreateLogger <BlogManager>(); IOptions <BlogManagerOptions> optsAccessor = BuildBlogManagerOptions(sandbox); var modifiableOptsAccessor = BuildBlogManagerModifiableOptions(sandbox); var bm = new BlogManager(logger, dasBlogSettings); var cacheFixer = ServiceProvider.GetService <ICacheFixer>(); cacheFixer.InvalidateCache(bm); return(bm); }
private IConfiguration GetDasBlogAppConfiguration(IDasBlogSandbox sandbox) { var staging = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty; ConfigurationBuilder configBuilder = new ConfigurationBuilder(); configBuilder .SetBasePath(sandbox.TestEnvironmentPath) .AddXmlFile(@"Config/site.config", optional: true, reloadOnChange: true) .AddXmlFile(@"Config/metaConfig.xml", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() ; return(configBuilder.Build()); }
/// <summary> /// returns a fully functional blog manager object pointed at the environment provided /// </summary> /// <param name="environment">e.g. "Vanilla"</param> /// <returns>ready for anything</returns> public BlogManager CreateBlogManager(IDasBlogSandbox sandbox) { var dasBlogSettings = CreateDasBlogSettings(sandbox); ILogger <BlogManager> logger = ServiceProvider.GetService <ILoggerFactory>().CreateLogger <BlogManager>(); IOptions <BlogManagerOptions> optsAccessor = BuildBlogManagerOptions(sandbox); var modifiableOptsAccessor = BuildBlogManagerModifiableOptions(sandbox); var bm = new BlogManager(/*dasBlogSettings,*/ logger, optsAccessor, modifiableOptsAccessor , new OptionsWrapper <BlogManagerExtraOptions>(new BlogManagerExtraOptions { ContentRootPath = sandbox.TestEnvironmentPath })); var cacheFixer = ServiceProvider.GetService <ICacheFixer>(); cacheFixer.InvalidateCache(bm); return(bm); }
/// <summary> /// completes the platform setup after the logger has been created although /// it's not clear that the instantiation has to take place after the logger has been configured. /// </summary> protected override void CompleteSetupLocal() { Runner = ServiceProvider.GetService <IWebServerRunner>(); Browser = ServiceProvider.GetService <IBrowser>(); TestExecutor = ServiceProvider.GetService <ITestExecutor>(); Publisher = ServiceProvider.GetService <IPublisher>(); Pages = new Pages(Browser); var sandboxFactory = ServiceProvider.GetService <IDasBlogSandboxFactory>(); sandbox = sandboxFactory.CreateSandbox(ServiceProvider, Constants.VanillaEnvironment); sandbox.Init(); Environment.SetEnvironmentVariable(WebAppConstants.DasBlogDataRoot, sandbox.TestEnvironmentPath); this.Runner.RunDasBlog(); this.Browser.Init(); }
public ITestDataProcessor CreateTestDataProcessor(IDasBlogSandbox sandbox) { return(new TestDataProcesor(sandbox.TestEnvironmentPath)); }
public ITestDataProcessor CreateTestDataProcessor(IDasBlogSandbox sandbox) { return(ServiceProvider.GetService <ITestDataProcesorFactory>().CreateTestDataProcessor(sandbox)); }
private IOptionsMonitor <BlogManagerModifiableOptions> BuildBlogManagerModifiableOptions(IDasBlogSandbox sandbox) { var configuration = GetDasBlogAppConfiguration(sandbox); return(new FakeOptionsMonitor <BlogManagerModifiableOptions>( new OptionsBuilder <BlogManagerModifiableOptions>().Build(configuration))); }
public DasBlogSandboxTests(ITestOutputHelper testOutputHelper, InfrastructureTestPlatform platform) { this.platform = platform; this.platform.CompleteSetup(testOutputHelper); dasBlogSandbox = platform.CreateSandbox(Constants.VanillaEnvironment); }
public XPathTests(ITestOutputHelper testOutputHelper, InfrastructureTestPlatform platform) { platform.CompleteSetup(testOutputHelper); dasBlogSandbox = platform.CreateSandbox(Constants.VanillaEnvironment); testDataProcessor = new TestDataProcesor(dasBlogSandbox.TestEnvironmentPath); }