diff --git a/Yavsc/Views/Project/Index.cshtml b/Yavsc/Views/Project/Index.cshtml
index 519a440b..e206d884 100644
--- a/Yavsc/Views/Project/Index.cshtml
+++ b/Yavsc/Views/Project/Index.cshtml
@@ -11,6 +11,9 @@
+
+ @Html.DisplayNameFor(model => model.Name)
+ |
@Html.DisplayNameFor(model => model.Consent)
|
@@ -55,6 +58,9 @@
@foreach (var item in Model) {
+
+ @Html.DisplayFor(modelItem => item.Name)
+ |
@Html.DisplayFor(modelItem => item.Consent)
|
diff --git a/cli/Program.cs b/cli/Program.cs
index acb7b52d..872e1304 100644
--- a/cli/Program.cs
+++ b/cli/Program.cs
@@ -1,25 +1,8 @@
-using System;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.OptionsModel;
-
-using System.Globalization;
-using System.Reflection;
// using Microsoft.AspNet.Authorization;
-using Microsoft.AspNet.Builder;
// using Microsoft.AspNet.Diagnostics;
using Microsoft.AspNet.Hosting;
-using Microsoft.AspNet.Identity;
-using Microsoft.AspNet.Identity.EntityFramework;
-using Microsoft.AspNet.Localization;
-using Microsoft.AspNet.Mvc;
-using Microsoft.AspNet.Mvc.Filters;
-using Microsoft.AspNet.Mvc.Razor;
-using Microsoft.Net.Http.Headers;
-using Microsoft.AspNet.Razor;
-using Microsoft.Extensions.DependencyInjection.Abstractions;
-using Microsoft.Extensions.PlatformAbstractions;
using cli.Services;
namespace cli
diff --git a/cli/Services/EMailer.cs b/cli/Services/EMailer.cs
index ce2afa32..0393d197 100644
--- a/cli/Services/EMailer.cs
+++ b/cli/Services/EMailer.cs
@@ -1,29 +1,23 @@
using System;
using System.IO;
-using System.CodeDom;
-using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using System.Text;
+using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.AspNet.Razor;
-using Microsoft.AspNet.Razor.Generator;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
-using Microsoft.CSharp;
using Microsoft.AspNet.Identity.EntityFramework;
-using Newtonsoft.Json;
using Yavsc.Models;
-using Yavsc.Models.Identity;
using Yavsc.Templates;
using Yavsc.Abstract.Templates;
using Yavsc.Services;
-
+using Yavsc.Abstract.Manage;
namespace cli.Services
{
@@ -172,13 +166,17 @@ namespace cli.Services
generatedtemplate.User = user;
generatedtemplate.ExecuteAsync();
logger.LogInformation(generatedtemplate.GeneratedText);
- var mailSentInfo = this.mailSender.SendEmailAsync
- (user.UserName, user.Email, $"monthly email", generatedtemplate.GeneratedText).Result;
- if (!mailSentInfo.Sent)
+ EmailSentViewModel mailSentInfo = this.mailSender.SendEmailAsync
+ (user.UserName, user.Email, $"monthly email", generatedtemplate.GeneratedText).Result;
+ if (mailSentInfo==null)
+ logger.LogError("No info on sending");
+ else if (!mailSentInfo.Sent)
logger.LogError($"{mailSentInfo.ErrorMessage}");
else
logger.LogInformation($"mailId:{mailSentInfo.MessageId} \nto:{user.UserName}");
+
+
}
}
diff --git a/cli/Startup.cs b/cli/Startup.cs
index ebe09199..676a50ae 100644
--- a/cli/Startup.cs
+++ b/cli/Startup.cs
@@ -57,7 +57,7 @@ namespace cli
var smtpSettingsconf = Configuration.GetSection("Smtp");
services.Configure(smtpSettingsconf);
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
- services.AddTransient(typeof(IEmailSender), typeof(MessageSender));
+ services.AddTransient(typeof(IEmailSender), typeof(MailSender));
services.AddTransient(typeof(RazorEngineHost), typeof(YaRazorEngineHost));
services.AddEntityFramework().AddNpgsql().AddDbContext();
services.AddTransient((s) => new RazorTemplateEngine(s.GetService()));
diff --git a/cli/project.json b/cli/project.json
index c06bd675..a7caf892 100644
--- a/cli/project.json
+++ b/cli/project.json
@@ -44,15 +44,15 @@
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta4",
"Newtonsoft.Json": "9.0.1",
"Yavsc": {
- "version": "1.0.5-rc21-beta7",
+ "version": "1.0.5-rc21-beta8",
"target": "package"
},
"Yavsc.Abstract": {
- "version": "1.0.5-rc21-beta7",
+ "version": "1.0.5-rc21-beta8",
"target": "package"
},
"Yavsc.Server": {
- "version": "1.0.5-rc21-beta7",
+ "version": "1.0.5-rc21-beta8",
"target": "package"
},
"Yavsc.Lib.Portable": "1.0.2"
diff --git a/rc-num.txt b/rc-num.txt
index 81cd254a..03e9fadc 100644
--- a/rc-num.txt
+++ b/rc-num.txt
@@ -1 +1 @@
-21-beta7
+21-beta8
diff --git a/test/YavscServerFactory.cs b/test/YavscServerFactory.cs
new file mode 100644
index 00000000..36b0c9da
--- /dev/null
+++ b/test/YavscServerFactory.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.AspNet.Hosting.Server;
+using Microsoft.AspNet.Http.Features;
+using Microsoft.Extensions.Configuration;
+using Yavsc.Models;
+
+namespace Yavsc.Server
+{
+ public class cliServerFactory : IServerFactory
+ {
+ public IFeatureCollection Initialize(IConfiguration configuration)
+ {
+ FeatureCollection featureCollection = new FeatureCollection();
+ return featureCollection;
+ }
+
+ public IDisposable Start(IFeatureCollection serverFeatures, Func application)
+ {
+ var task = application(serverFeatures);
+ return task;
+ }
+ }
+}
diff --git a/test/appsettings.json b/test/appsettings.json
new file mode 100644
index 00000000..682807de
--- /dev/null
+++ b/test/appsettings.json
@@ -0,0 +1,24 @@
+{
+ "Site": {
+ "Authority": "dev.pschneider.fr",
+ "Title": "Yavsc dev",
+ "Slogan": "Yavsc : WIP.",
+ "Banner": "/images/yavsc.png",
+ "HomeViewName": "Home",
+ "FavIcon": "/favicon.ico",
+ "Icon": "/images/yavsc.png"
+ },
+ "Logging": {
+ "IncludeScopes": true,
+ "LogLevel": {
+ "Default": "Debug",
+ "System": "Warning",
+ "Microsoft": "Warning"
+ }
+ },
+ "Data": {
+ "DefaultConnection": {
+ "ConnectionString": "Server=localhost;Port=5432;Database=YavscDev;Username=yavscdev;Password=admin;"
+ }
+ }
+}
diff --git a/test/project.json b/test/project.json
index 61738f3d..4e5b8956 100644
--- a/test/project.json
+++ b/test/project.json
@@ -28,24 +28,23 @@
"defaultNamespace": "Yavsc"
},
"dependencies": {
- "Yavsc": {
- "target": "project"
- },
"Newtonsoft.Json": "9.0.1",
"xunit": "2.1.0",
"xunit.analyzers": "0.9.0",
"xunit.assert": "2.1.0",
- "xunit.runner.console": "2.1.0",
+ "xunit.runner.console": "2.4.0-rc.2.build4045",
"Microsoft.Dnx.TestHost": "1.0.0-rc1-final",
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
"xunit.runner.dnx": "2.1.0-rc1-build204",
- "Yavsc.Abstract": "1.0.5-rc21-beta5",
- "Yavsc.Server": "1.0.5-rc21-beta5"
+ "Yavsc": {
+ "target": "project"
+ }
},
"frameworks": {
"dnx451": {}
},
"commands": {
"test": "xunit.runner.dnx"
- }
-}
+ },
+ "userSecretsId": "aspnet5-YavscWeb-a0dadd21-2ced-43d3-96f9-7e504345102f"
+}
\ No newline at end of file
diff --git a/test/src/EMailling.cs b/test/src/EMailling.cs
new file mode 100644
index 00000000..19b4a222
--- /dev/null
+++ b/test/src/EMailling.cs
@@ -0,0 +1,43 @@
+using System;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Hosting.Internal;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.OptionsModel;
+using Xunit;
+using Xunit.Abstractions;
+using Yavsc.Abstract.Manage;
+using Yavsc.Lib;
+using Yavsc.Services;
+
+namespace Yavsc.test
+{
+
+ [Collection("EMaillingTeststCollection")]
+ public class EMaillingTests : IClassFixture
+
+ {
+ ServerSideFixture _serverFixture;
+ ITestOutputHelper output;
+ public EMaillingTests(ServerSideFixture serverFixture, ITestOutputHelper output)
+ {
+ this.output = output;
+ _serverFixture = serverFixture;
+ }
+
+ [Fact]
+ public void SendEMailSynchrone()
+ {
+ output.WriteLine("SendEMailSynchrone ...");
+ EmailSentViewModel mailSentInfo = _serverFixture._mailSender.SendEmailAsync
+ (_serverFixture._siteSetup.Owner.Name, _serverFixture._siteSetup.Owner.EMail, $"monthly email", "test boby monthly email").Result;
+ if (mailSentInfo==null)
+ _serverFixture._logger.LogError("No info on sending");
+ else if (!mailSentInfo.Sent)
+ _serverFixture._logger.LogError($"{mailSentInfo.ErrorMessage}");
+ else
+ _serverFixture._logger.LogInformation($"mailId:{mailSentInfo.MessageId} \nto:{_serverFixture._siteSetup.Owner.Name}");
+ Assert.NotNull(mailSentInfo);
+ output.WriteLine($">>done with {mailSentInfo.EMail} {mailSentInfo.Sent} {mailSentInfo.MessageId} {mailSentInfo.ErrorMessage}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/src/NotWorking.cs b/test/src/NotWorking.cs
new file mode 100644
index 00000000..e138d143
--- /dev/null
+++ b/test/src/NotWorking.cs
@@ -0,0 +1,54 @@
+// // NotWorking.cs
+// /*
+// paul 21/06/2018 10:16 20182018 6 21
+// */
+using System;
+using Microsoft.AspNet.Builder;
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.OptionsModel;
+using Microsoft.Extensions.PlatformAbstractions;
+using Xunit;
+using Microsoft.Dnx.Compilation.CSharp;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Configuration;
+using Microsoft.AspNet.Builder.Internal;
+using Yavsc;
+using Microsoft.Extensions.Logging;
+
+namespace Test
+{
+ [Collection("Yavsc dropped intents")]
+ public class NotWorking : BaseTestContext
+ {
+
+ public void StringLocalizer()
+ {
+ var services = new ServiceCollection();
+ // IHostingEnvironment env = null;
+ // IOptions siteSettings;
+
+ services.AddTransient(
+ svs => PlatformServices.Default.Runtime
+ );
+ beforeCompileContext = YavscMandatory.CreateYavscCompilationContext();
+ var prjDir = beforeCompileContext.ProjectContext.ProjectDirectory;
+ YavscMandatory.ConfigureServices(services, prjDir, out configuration, out provider);
+
+ IApplicationBuilder app = new ApplicationBuilder(provider);
+ var rtd = app.Build();
+ IOptions localOptions = Activator.CreateInstance>(); ;
+ // TODO build applicationEnvironment
+ ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory
+ (applicationEnvironment, localOptions);
+ IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
+ }
+
+ public void NoDnxEnv()
+ {
+
+ IOptions localOptions = Activator.CreateInstance>();
+ ResourceManagerStringLocalizerFactory strFact = new ResourceManagerStringLocalizerFactory(applicationEnvironment, localOptions);
+ IStringLocalizer stringLocalizer = strFact.Create(typeof(NotWorking));
+ }
+ }
+}
diff --git a/test/src/Program.cs b/test/src/Program.cs
new file mode 100644
index 00000000..7f9d0d69
--- /dev/null
+++ b/test/src/Program.cs
@@ -0,0 +1,29 @@
+using Microsoft.AspNet.Hosting;
+using Microsoft.Extensions.Logging;
+using Yavsc.Lib;
+using Yavsc.Services;
+
+namespace Yavsc.test
+{
+ public class Program
+ {
+ public Program()
+ {
+ var host = new WebHostBuilder();
+
+ var hostengnine = host
+ .UseEnvironment("Development")
+ .UseServer("test")
+ .UseStartup()
+ .Build();
+
+ var app = hostengnine.Start();
+ var sender = app.Services.GetService(typeof(IEmailSender)) as IEmailSender;
+ var mailer = app.Services.GetService(typeof(EMailer)) as EMailer;
+ var loggerFactory = app.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
+ ILogger logger = loggerFactory.CreateLogger() ;
+ mailer.SendMonthlyEmail(1,"UserOrientedTemplate");
+ logger.LogInformation("Finished");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/src/ServerSideFixture.cs b/test/src/ServerSideFixture.cs
new file mode 100644
index 00000000..49a6a72a
--- /dev/null
+++ b/test/src/ServerSideFixture.cs
@@ -0,0 +1,48 @@
+using System;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Hosting.Internal;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.OptionsModel;
+using Yavsc.Lib;
+using Yavsc.Services;
+
+namespace Yavsc.test
+{
+ public class ServerSideFixture : IDisposable {
+ public SiteSettings _siteSetup;
+ public ILogger _logger;
+ public IApplication _app;
+ public EMailer _mailer;
+ public ILoggerFactory _loggerFactory;
+ public IEmailSender _mailSender;
+
+ public ServerSideFixture()
+ {
+ InitServices();
+ _logger = _loggerFactory.CreateLogger ();
+ _logger.LogInformation("ServerSideFixture");
+ }
+ void InitServices()
+ {
+ var host = new WebHostBuilder();
+
+ var hostengnine = host
+ .UseEnvironment("Development")
+ .UseServer("test")
+ .UseStartup()
+ .Build();
+
+ _app = hostengnine.Start();
+ _mailer = _app.Services.GetService(typeof(EMailer)) as EMailer;
+ _loggerFactory = _app.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;
+ var siteSetup = _app.Services.GetService(typeof(IOptions)) as IOptions;
+ _siteSetup = siteSetup.Value;
+ _mailSender = _app.Services.GetService(typeof(IEmailSender)) as IEmailSender;
+ }
+
+ public void Dispose()
+ {
+ _logger.LogInformation("Disposing");
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/src/Startup.cs b/test/src/Startup.cs
new file mode 100644
index 00000000..106671dc
--- /dev/null
+++ b/test/src/Startup.cs
@@ -0,0 +1,100 @@
+using System;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.OptionsModel;
+using Microsoft.AspNet.Builder;
+using Microsoft.AspNet.Hosting;
+using Microsoft.AspNet.Razor;
+using Microsoft.Extensions.PlatformAbstractions;
+using Yavsc;
+using Yavsc.Models;
+using Yavsc.Services;
+using Microsoft.Data.Entity;
+using Microsoft.AspNet.Authentication;
+using Microsoft.Extensions.WebEncoders;
+using Yavsc.Lib;
+
+namespace Yavsc.test
+{
+ public class Startup
+ {
+ public string ConnectionString
+ {
+ get ; set;
+ }
+
+ public static SiteSettings SiteSetup { get; private set; }
+ public static SmtpSettings SmtpSettup { get; private set; }
+ public static IConfiguration Configuration { get; set; }
+
+ public static string HostingFullName { get; private set; }
+
+ ILogger logger;
+ public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
+ {
+ var devtag = env.IsDevelopment()?"D":"";
+ var prodtag = env.IsProduction()?"P":"";
+ var stagetag = env.IsStaging()?"S":"";
+
+ HostingFullName = $"{appEnv.RuntimeFramework.FullName} [{env.EnvironmentName}:{prodtag}{devtag}{stagetag}]";
+ // Set up configuration sources.
+
+ var builder = new ConfigurationBuilder()
+ .AddEnvironmentVariables()
+ .AddJsonFile("appsettings.json")
+ .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
+ Configuration = builder.Build();
+ ConnectionString = Configuration["Data:DefaultConnection:ConnectionString"];
+ AppDomain.CurrentDomain.SetData("YAVSC_CONNECTION", ConnectionString);
+ }
+
+ public void ConfigureServices (IServiceCollection services)
+ {
+ services.AddOptions();
+ var siteSettingsconf = Configuration.GetSection("Site");
+ services.Configure(siteSettingsconf);
+ var smtpSettingsconf = Configuration.GetSection("Smtp");
+ services.Configure(smtpSettingsconf);
+ services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
+ services.AddTransient(typeof(IEmailSender), typeof(MailSender));
+ services.AddEntityFramework().AddNpgsql().AddDbContext();
+ services.AddTransient((s) => new RazorTemplateEngine(s.GetService()));
+ services.AddLogging();
+ services.AddTransient();
+ services.AddLocalization(options =>
+ {
+ options.ResourcesPath = "Resources";
+ });
+
+ services.AddEntityFramework()
+ .AddNpgsql()
+ .AddDbContext(
+ db => db.UseNpgsql(ConnectionString)
+ );
+ services.Configure(options =>
+ {
+ options.SignInScheme = "Bearer";
+ });
+
+ services.AddTransient();
+
+ services.AddAuthentication();
+
+ }
+
+ public void Configure (IApplicationBuilder app, IHostingEnvironment env,
+ IOptions siteSettings, ILoggerFactory loggerFactory)
+ {
+ loggerFactory.AddConsole(Configuration.GetSection("Logging"));
+ loggerFactory.AddDebug();
+ logger = loggerFactory.CreateLogger();
+ logger.LogInformation(env.EnvironmentName);
+ var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
+ var clientId = authConf.GetSection("ClientId").Value;
+ var clientSecret = authConf.GetSection("ClientSecret").Value;
+
+ }
+
+ }
+}
diff --git a/test/src/YavscMandatory.cs b/test/src/YavscMandatory.cs
new file mode 100755
index 00000000..a4b895c3
--- /dev/null
+++ b/test/src/YavscMandatory.cs
@@ -0,0 +1,233 @@
+using System;
+using Microsoft.AspNet.Builder;
+using Microsoft.AspNet.Builder.Internal;
+using Microsoft.AspNet.Razor;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Localization;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.PlatformAbstractions;
+using Xunit;
+using Yavsc;
+using Yavsc.Models;
+using Yavsc.Services;
+using System.Runtime.Versioning;
+using Microsoft.AspNet.Mvc.Razor;
+using System.Diagnostics;
+using Microsoft.Dnx.Compilation.CSharp;
+using Microsoft.Extensions.OptionsModel;
+using Yavsc.Helpers;
+using Microsoft.Data.Entity;
+using Xunit.Abstractions;
+using System.IO;
+
+namespace Test
+{
+ public class BaseTestContext {
+ protected IApplicationEnvironment applicationEnvironment = null;
+ protected IServiceProvider serviceProvider = null;
+ protected IConfigurationRoot configurationRoot;
+ protected BeforeCompileContext beforeCompileContext;
+ protected string testprojectAssetPath = "/home/paul/workspace/yavsc/Yavsc";
+
+ protected IServiceProvider provider;
+ protected IConfigurationRoot configuration;
+ }
+
+ [Collection("Yavsc mandatory success story")]
+ public class YavscMandatory: BaseTestContext
+ {
+ private readonly ITestOutputHelper output;
+ public YavscMandatory(ITestOutputHelper output)
+ {
+ this.output = output;
+ }
+
+ [Fact]
+ void TestStartNodeJsansitohtml()
+ {
+ var procStart = new ProcessStartInfo("env", "/usr/bin/nodejs node_modules/ansi-to-html/bin/ansi-to-html");
+ procStart.UseShellExecute = false;
+ procStart.RedirectStandardInput = true;
+ procStart.RedirectStandardOutput = true;
+ procStart.RedirectStandardError = true;
+ var proc = Process.Start(procStart);
+
+ proc.StandardInput.WriteLine("\x001b[30mblack\x1b[37mwhite");
+ proc.StandardInput.Close();
+ while (!proc.StandardOutput.EndOfStream)
+ {
+ output.WriteLine(proc.StandardOutput.ReadLine());
+ }
+ }
+
+ // actually uses node's ansi-to-html
+ [Fact]
+ void AnsiToHtml()
+ {
+ var procStart = new ProcessStartInfo("ls", "-l --color=always");
+ procStart.UseShellExecute = false;
+ procStart.RedirectStandardInput = false;
+ procStart.RedirectStandardOutput = true;
+ var proc = Process.Start(procStart);
+ var encoded = AnsiToHtmlEncoder.GetStream(proc.StandardOutput);
+ using (var reader = new StreamReader(encoded))
+ {
+ var txt = reader.ReadToEnd();
+ output.WriteLine(txt);
+ }
+ }
+
+ [Fact]
+ public void ApplicationDbContextExists()
+ {
+ var dbc = new ApplicationDbContext();
+ Assert.NotNull(dbc.GCMDevices);
+ }
+
+ [Fact]
+ public void MvcRazorHostAndParser()
+ {
+ string cache = System.IO.Directory.GetCurrentDirectory();
+ MvcRazorHost host = new MvcRazorHost(cache);
+ var parser = host.CreateMarkupParser();
+ }
+
+ [Fact]
+ void HaveDependecyInjection()
+ {
+ var services = new ServiceCollection();
+ }
+
+ [Fact]
+ void HaveHost()
+ {
+ beforeCompileContext = CreateYavscCompilationContext();
+ }
+
+ [Fact]
+ public void AConfigurationRoot()
+ {
+ var builder = new ConfigurationBuilder();
+ builder.AddJsonFile(Path.Combine(testprojectAssetPath, "appsettings.json"), false);
+ builder.AddJsonFile(Path.Combine(testprojectAssetPath, "appsettings.Development.json"), true);
+ configurationRoot = builder.Build();
+ }
+
+ internal static BeforeCompileContext CreateYavscCompilationContext()
+ {
+ var projectContext = new ProjectContext();
+ projectContext.Name = "Yavsc";
+ projectContext.ProjectDirectory = "/home/paul/workspace/yavsc/Yavsc";
+ projectContext.ProjectFilePath = "/home/paul/workspace/yavsc/Yavsc/project.json";
+ projectContext.TargetFramework = new FrameworkName("DNX", new Version(4, 5, 1));
+ projectContext.Configuration = "Development";
+
+ return new BeforeCompileContext(
+ null, projectContext, () => null, () => null, () => null);
+ }
+
+ internal static IConfigurationRoot CreateConfiguration(string prjDir)
+ {
+ var builder = new ConfigurationBuilder();
+
+ builder.AddJsonFile(Path.Combine(prjDir, "appsettings.json"), true);
+ builder.AddJsonFile(Path.Combine(prjDir, "appsettings.Development.json"), true);
+ return builder.Build();
+ }
+
+ internal static void ConfigureServices
+ (ServiceCollection serviceCollection,
+ string prjDir,
+ out IConfigurationRoot configuration,
+ out IServiceProvider provider)
+ {
+ configuration = CreateConfiguration(prjDir);
+
+ serviceCollection.AddOptions();
+ var siteSettingsconf = configuration.GetSection("Site");
+ serviceCollection.Configure(siteSettingsconf);
+ var smtpSettingsconf = configuration.GetSection("Smtp");
+ serviceCollection.Configure(smtpSettingsconf);
+ var locOptions = configuration.GetSection("Localization");
+ serviceCollection.Configure(locOptions);
+
+ serviceCollection.AddSingleton(typeof(ILoggerFactory), typeof(LoggerFactory));
+ serviceCollection.AddTransient(typeof(IEmailSender), typeof(MailSender));
+ serviceCollection.AddTransient(typeof(RazorEngineHost));
+ serviceCollection.AddTransient((s) => new RazorTemplateEngine(s.GetService()));
+ serviceCollection.AddLogging();
+ serviceCollection.AddMvcCore();
+ serviceCollection.AddLocalization(options =>
+ {
+ options.ResourcesPath = "Resources";
+ });
+ var connectionString = configuration["Data:DefaultConnection:ConnectionString"];
+ AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", connectionString);
+ serviceCollection.AddEntityFramework()
+ .AddNpgsql()
+ .AddDbContext(
+ db => db.UseNpgsql(connectionString)
+ );
+ provider = serviceCollection.BuildServiceProvider();
+ }
+
+
+ [Fact]
+ public void ARequestAppDelegate()
+ {
+ var services = new ServiceCollection();
+
+ services.AddTransient(
+ svs => PlatformServices.Default.Runtime
+ );
+
+ HaveHost();
+ var prjDir = this.beforeCompileContext.ProjectContext.ProjectDirectory;
+ ConfigureServices(services, prjDir, out configurationRoot, out serviceProvider);
+
+ IApplicationBuilder app = new ApplicationBuilder(serviceProvider);
+ var rtd = app.Build();
+
+ }
+
+
+ [Fact]
+ public void MessageSenderFromLib()
+ {
+ ARequestAppDelegate();
+ ILoggerFactory factory = ActivatorUtilities.GetServiceOrCreateInstance(serviceProvider);
+ var dbc = new ApplicationDbContext();
+
+ IOptions siteOptions =
+ ActivatorUtilities.GetServiceOrCreateInstance>(serviceProvider);
+ ;
+ IOptions smtpOptions = ActivatorUtilities.GetServiceOrCreateInstance>(serviceProvider);
+ ;
+ IOptions googleOptions = ActivatorUtilities.GetServiceOrCreateInstance>(serviceProvider);
+ ;
+ IEmailSender eSender = new MailSender
+ (factory, siteOptions, smtpOptions, googleOptions);
+ }
+
+ [Fact]
+ public void InitApplicationBuilder()
+ {
+
+ var services = new ServiceCollection();
+
+ services.AddTransient(
+ svs => PlatformServices.Default.Runtime
+ );
+ beforeCompileContext = YavscMandatory.CreateYavscCompilationContext();
+ var prjDir = beforeCompileContext.ProjectContext.ProjectDirectory;
+ YavscMandatory.ConfigureServices(services, prjDir, out configuration, out provider);
+
+ IApplicationBuilder app = new ApplicationBuilder(provider);
+ app.UseMvc();
+ var rtd = app.Build();
+ IOptions localOptions = ActivatorUtilities.GetServiceOrCreateInstance>(provider); ;
+
+ }
+ }
+}
diff --git a/test/src/YavscWorkInProgress.cs b/test/src/YavscWorkInProgress.cs
index cbe2af29..7f6f117e 100644
--- a/test/src/YavscWorkInProgress.cs
+++ b/test/src/YavscWorkInProgress.cs
@@ -24,7 +24,6 @@ namespace Test
public class YavscWorkInProgress : BaseTestContext
{
- [Fact]
public void GitClone()
{