// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <OrdersDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("FokOrdersDB")); }); services.AddScoped <IOrdersService, OrdersService>(); services.AddSingleton <IOrdersEventManager, OrdersEventManager>(); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <DeliveriesDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("FokDeliveriesDB"), x => x.UseNetTopologySuite()); }); services.AddScoped <IDeliveryService, DeliveryService>(); services.AddScoped <IRiderService, RiderService>(); services.AddSingleton <ILogService, LogService>(); services.AddHostedService <RiderHandlerHostedService>(); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.DateTimeItFormatter(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var notificationConfigSection = Configuration.GetSection("NotificationHubConfig"); var notifications = new Notifications(notificationConfigSection["SubscriptionId"], notificationConfigSection["Name"]); services.AddSingleton <Notifications>(notifications); services.AddSingleton <INotificationEventManager, NotificationEventsManager>(); services.Configure <NotificationHubConfig>(Configuration.GetSection("NotificationHubConfig")); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.DateTimeItFormatter(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <RestaurantsDbContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("FokRestaurantsDB")); }); //registering restaurants service services.AddScoped <IRestaurantService, RestaurantService>(); services.AddScoped <IRestaurantMenuService, RestaurantMenuService>(); //registering bus event manager services.AddSingleton <IRestaurantsEventsManager, RestaurantsEventsManager>(); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ReviewsDBContext>(options => { options.UseSqlServer(Configuration.GetConnectionString("FokReviewsDB")); }); //registering feedbackservice service services.AddScoped <IReviewService, ReviewService>(); services.AddSingleton <ILogService, LogService>(); //registering bus event manager services.AddSingleton <IReviewEventsManager, ReviewEventsManager>(); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.DateTimeItFormatter(); }
public async Task InvokeLogHandler_Test() { var applicationInsightsMock = new ApplicationInsightsSettings() { InstrumentationKey = "118047f1-b165-4bff-9471-e87fd3fe167c" }; _applicationInsightsMock.Setup(x => x.Value) .Returns(applicationInsightsMock); var httpContext = new DefaultHttpContext().Request.HttpContext; var logMiddleware = new LogMiddleware(async(innerHttpContext) => { await innerHttpContext.Response.WriteAsync("Response body mock"); }, _applicationInsightsMock.Object); await logMiddleware.Invoke(httpContext, _identityServiceMock.Object); Assert.NotNull(logMiddleware); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddStackExchangeRedisCache(opt => { opt.Configuration = Configuration.GetSection("RedisConfig").GetValue <string>("connection"); }); services.AddScoped <IBasketService, BasketService>(); services.AddScoped <IBasketRepository, RedisBasketRepository>(); services.Configure <RedisConfig>(Configuration.GetSection("RedisConfig")); services.AddSingleton <ConnectionMultiplexer>(sp => { var configuration = ConfigurationOptions.Parse(Configuration.GetSection("RedisConfig").GetValue <string>("connection"), true); configuration.ResolveDns = true; return(ConnectionMultiplexer.Connect(configuration)); }); services.AddSingleton <Microsoft.Extensions.Hosting.IHostedService, BasketEventsManager>(); LogMiddleware.AddRabbitMQConfiguration(services, Configuration); }
public async Task InvokeLogHandler_Test() { var fakeChannel = new TelemetryChannelMock(); var config = new TelemetryConfiguration { TelemetryChannel = fakeChannel, InstrumentationKey = string.Empty, }; var client = new TelemetryClient(config); var httpContext = new DefaultHttpContext().Request.HttpContext; httpContext.Request.Method = HttpMethods.Post; var logMiddleware = new LogMiddleware(async(innerHttpContext) => { await innerHttpContext.Response.WriteAsync("Response body mock"); }, client); await logMiddleware.Invoke(httpContext, _identityServiceMock.Object); Assert.NotNull(logMiddleware); }