Skip to content

Instantly share code, notes, and snippets.

View dmitry-zaets's full-sized avatar
:shipit:
Open for the new projects

Dmitry Zaets dmitry-zaets

:shipit:
Open for the new projects
View GitHub Profile
@dmitry-zaets
dmitry-zaets / stripeElements.test.js
Last active December 4, 2018 17:56
Testing Stripe Element fields with Nigthwatch.js
module.exports = {
'Create a paid listing': function(browser) {
browser
.init()
.waitForElementVisible('body', 1000)
// Code to navigate to payment form
// Stripe card
.waitForElementPresent('.e2e-card-number iframe', 10000)
.element('css selector', '.e2e-card-number iframe', el => {
browser
<appSettings>
<add key="mySetting" value="Pain" />
</appSettings>
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile(“config.json”, optional: true, reloadOnChange: true)
.AddJsonFile($”appsettings.{env.EnvironmentName}.json”, optional: true)
.AddEnvironmentVariables();
public static void RegisterOptions(this ContainerBuilder builder)
{
builder.RegisterGeneric(typeof(OptionsManager<>))
.As(typeof(IOptions<>))
.SingleInstance();
builder.RegisterGeneric(typeof(OptionsMonitor<>))
.As(typeof(IOptionsMonitor<>))
.SingleInstance();
builder.RegisterGeneric(typeof(OptionsSnapshot<>))
.As(typeof(IOptionsSnapshot<>))
public static void RegisterConfigurationOptions<TOptions>(this ContainerBuilder builder, IConfiguration config) where TOptions : class
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (config == null)
{
throw new ArgumentNullException(nameof(config));
public class HomeController : Controller
{
private ApiOptions _apiOptions;
public HomeController(IOptions<ApiOptions> apiOptions)
{
_apiOptions= apiOptions.Value;
}
public IActionResult Index()
{
return Content($"Api Name = {_apiOptions.Name}");
public class Endpoint
{
public string Name { get; set; }
public string Url { get; set; }
}
public static void Configure<TOptions>(this ContainerBuilder builder, Action<TOptions> configureOptions) where TOptions : class
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}
if (configureOptions == null)
{
throw new ArgumentNullException(nameof(configureOptions));
}
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Path.Combine(HttpRuntime.AppDomainAppPath, "configs"))
.AddJsonFile("settings.json", optional: false);
var configuration = configurationBuilder.Build();
var builder = new ContainerBuilder();
builder.RegisterOptions();
builder.RegisterConfigurationOptions<MailingOptions>(configuration.GetSection("mailing"));
builder.RegisterConfigurationOptions<FeedOptions>(configuration.GetSection("feed"));
public class ApiOptions
{
public string Name { get; set; }
public List<ApiEndpoint> Endpoints { get; set; }
}
public class ApiEndpoint
{
public string Url { get; set; }
public bool RetryOnFailure { get; set; }
public List<ApiEvent> AvailableEvents { get; set; }