parent
3505d5aa6c
commit
5f26e97f0a
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
using MimeKit;
|
||||
using Yavsc.Abstract.Manage;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
public class MailSender : IEmailSender
|
||||
{
|
||||
private ILogger _logger;
|
||||
SiteSettings siteSettings;
|
||||
SmtpSettings smtpSettings;
|
||||
|
||||
public MailSender(
|
||||
ILoggerFactory loggerFactory,
|
||||
IOptions<SiteSettings> sitesOptions,
|
||||
IOptions<SmtpSettings> smtpOptions,
|
||||
IOptions<GoogleAuthSettings> googleOptions
|
||||
)
|
||||
{
|
||||
_logger = loggerFactory.CreateLogger<MailSender>();
|
||||
siteSettings = sitesOptions?.Value;
|
||||
smtpSettings = smtpOptions?.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="googleSettings"></param>
|
||||
/// <param name="registrationId"></param>
|
||||
/// <param name="ev"></param>
|
||||
/// <returns>a MessageWithPayloadResponse,
|
||||
/// <c>bool somethingsent = (response.failure == 0 && response.success > 0)</c>
|
||||
/// </returns>
|
||||
|
||||
|
||||
public async Task<EmailSentViewModel> SendEmailAsync(string username, string email, string subject, string message)
|
||||
{
|
||||
EmailSentViewModel model = new EmailSentViewModel{ EMail = email };
|
||||
try
|
||||
{
|
||||
MimeMessage msg = new MimeMessage();
|
||||
msg.From.Add(new MailboxAddress(
|
||||
siteSettings.Owner.Name,
|
||||
siteSettings.Owner.EMail));
|
||||
msg.To.Add(new MailboxAddress(username, email));
|
||||
msg.Body = new TextPart("plain")
|
||||
{
|
||||
Text = message
|
||||
};
|
||||
msg.Subject = subject;
|
||||
msg.MessageId = MimeKit.Utils.MimeUtils.GenerateMessageId(
|
||||
siteSettings.Authority
|
||||
);
|
||||
using (SmtpClient sc = new SmtpClient())
|
||||
{
|
||||
sc.Connect(
|
||||
smtpSettings.Host,
|
||||
smtpSettings.Port,
|
||||
SecureSocketOptions.None);
|
||||
sc.Send(msg);
|
||||
model.MessageId = msg.MessageId;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
model.Sent = false;
|
||||
model.ErrorMessage = ex.Message;
|
||||
return model;
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using MailKit.Net.Smtp;
|
||||
using MimeKit;
|
||||
using MailKit.Security;
|
||||
using System;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Google.Messaging;
|
||||
using System.Collections.Generic;
|
||||
using Yavsc.Models.Haircut;
|
||||
using Yavsc.Interfaces.Workflow;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Yavsc.Abstract.Manage;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.OptionsModel;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
// This class is used by the application to send Email and SMS
|
||||
// when you turn on two-factor authentication in ASP.NET Identity.
|
||||
// For more details see this link http://go.microsoft.com/fwlink/?LinkID=532713
|
||||
|
||||
}
|
@ -1 +1 @@
|
||||
21-beta7
|
||||
21-beta8
|
||||
|
@ -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<IFeatureCollection, Task> application)
|
||||
{
|
||||
var task = application(serverFeatures);
|
||||
return task;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;"
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
||||
{
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Startup>()
|
||||
.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<Program>() ;
|
||||
mailer.SendMonthlyEmail(1,"UserOrientedTemplate");
|
||||
logger.LogInformation("Finished");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<ServerSideFixture> ();
|
||||
_logger.LogInformation("ServerSideFixture");
|
||||
}
|
||||
void InitServices()
|
||||
{
|
||||
var host = new WebHostBuilder();
|
||||
|
||||
var hostengnine = host
|
||||
.UseEnvironment("Development")
|
||||
.UseServer("test")
|
||||
.UseStartup<Startup>()
|
||||
.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<SiteSettings>)) as IOptions<SiteSettings>;
|
||||
_siteSetup = siteSetup.Value;
|
||||
_mailSender = _app.Services.GetService(typeof(IEmailSender)) as IEmailSender;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_logger.LogInformation("Disposing");
|
||||
}
|
||||
}
|
||||
}
|
@ -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<SiteSettings>(siteSettingsconf);
|
||||
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
||||
services.Configure<SmtpSettings>(smtpSettingsconf);
|
||||
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
||||
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
||||
services.AddEntityFramework().AddNpgsql().AddDbContext<ApplicationDbContext>();
|
||||
services.AddTransient((s) => new RazorTemplateEngine(s.GetService<RazorEngineHost>()));
|
||||
services.AddLogging();
|
||||
services.AddTransient<EMailer>();
|
||||
services.AddLocalization(options =>
|
||||
{
|
||||
options.ResourcesPath = "Resources";
|
||||
});
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddNpgsql()
|
||||
.AddDbContext<ApplicationDbContext>(
|
||||
db => db.UseNpgsql(ConnectionString)
|
||||
);
|
||||
services.Configure<SharedAuthenticationOptions>(options =>
|
||||
{
|
||||
options.SignInScheme = "Bearer";
|
||||
});
|
||||
|
||||
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
||||
|
||||
services.AddAuthentication();
|
||||
|
||||
}
|
||||
|
||||
public void Configure (IApplicationBuilder app, IHostingEnvironment env,
|
||||
IOptions<SiteSettings> siteSettings, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
logger = loggerFactory.CreateLogger<Startup>();
|
||||
logger.LogInformation(env.EnvironmentName);
|
||||
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
||||
var clientId = authConf.GetSection("ClientId").Value;
|
||||
var clientSecret = authConf.GetSection("ClientSecret").Value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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<SiteSettings>(siteSettingsconf);
|
||||
var smtpSettingsconf = configuration.GetSection("Smtp");
|
||||
serviceCollection.Configure<SmtpSettings>(smtpSettingsconf);
|
||||
var locOptions = configuration.GetSection("Localization");
|
||||
serviceCollection.Configure<LocalizationOptions>(locOptions);
|
||||
|
||||
serviceCollection.AddSingleton(typeof(ILoggerFactory), typeof(LoggerFactory));
|
||||
serviceCollection.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
||||
serviceCollection.AddTransient(typeof(RazorEngineHost));
|
||||
serviceCollection.AddTransient((s) => new RazorTemplateEngine(s.GetService<RazorEngineHost>()));
|
||||
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<ApplicationDbContext>(
|
||||
db => db.UseNpgsql(connectionString)
|
||||
);
|
||||
provider = serviceCollection.BuildServiceProvider();
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ARequestAppDelegate()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddTransient<IRuntimeEnvironment>(
|
||||
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<ILoggerFactory>(serviceProvider);
|
||||
var dbc = new ApplicationDbContext();
|
||||
|
||||
IOptions<SiteSettings> siteOptions =
|
||||
ActivatorUtilities.GetServiceOrCreateInstance<IOptions<SiteSettings>>(serviceProvider);
|
||||
;
|
||||
IOptions<SmtpSettings> smtpOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<SmtpSettings>>(serviceProvider);
|
||||
;
|
||||
IOptions<GoogleAuthSettings> googleOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<GoogleAuthSettings>>(serviceProvider);
|
||||
;
|
||||
IEmailSender eSender = new MailSender
|
||||
(factory, siteOptions, smtpOptions, googleOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InitApplicationBuilder()
|
||||
{
|
||||
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddTransient<IRuntimeEnvironment>(
|
||||
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<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue