protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); var container = ContainerFactory(); DependencyResolver.SetResolver(new AutofacDependencyResolver(container)); // MVC GlobalConfiguration.Configuration.DependencyResolver = new AutofacWebApiDependencyResolver(container); // WebApi // JSON formatting var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter; json.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); // Fix JSON.NET self referencing hell json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; _logger = DependencyResolver.Current.GetService<INLogger>(); _logger.Info("Application is starting"); //added for web api - return JSON instead of XML GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }
static void Main(string[] args) { try { // DI IKernel _kernal = new StandardKernel(); _kernal.Bind<INLogger>().To<NLogger>().InSingletonScope(); _kernal.Bind<IRepo>().To<Repo>().InSingletonScope(); _kernal.Bind<IOutputHelper>().To<OutputHelper>().InSingletonScope(); _logger = _kernal.Get<NLogger>(); _repo = _kernal.Get<Repo>(); _output = _kernal.Get<OutputHelper>(); //ValidateRunLengths(); var duplicates = ValidateIRIAVG(); var export = new ExcelExport().AddSheet("Duplicates", duplicates.ToArray()); export.ExportTo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), System.Configuration.ConfigurationManager.AppSettings["excel:exportFileName"].ToString())); } catch (Exception ex) { _output.Write(string.Format("Error: {0}", ex.Message), true); } Console.WriteLine("Done. Press any key to exist."); Console.ReadKey(); }
public void ResponseMessageIsLoggedForSuccessfulResponses() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var configSettings = new Settings { RequestCorrelationIdIsRequired = true }; var pipelineHelper = TestSetup.SetupPipelineHelper(configSettings, logger: _logger); var responseBody = new JObject(); responseBody.Add("Batman", "Begins"); var response = new Nancy.Response() { StatusCode = Nancy.HttpStatusCode.OK, Contents = stream => { using (var writer = new StreamWriter(stream)) { writer.Write(responseBody); } } }; // Act pipelineHelper.LogAndFormatResponse(response); // Assert _logger.Received(1).Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); Assert.AreEqual(Nancy.HttpStatusCode.OK, response.StatusCode); }
public HomeController( UserManager <AppUser> userManager, SignInManager <AppUser> signInManager, INLogger nLogger, IMapper mapper) : base(userManager) { _nLogger = nLogger; _signInManager = signInManager; _mapper = mapper; }
public ControlManager( INLogger logger, IProcessClient processClient, IWin32APIClient win32APIClient) { this.Logger = logger; this.ProcessClient = processClient; this.Win32APIClient = win32APIClient; }
public static void LogResponse(this INLogger logger, string message, Error error = null) { if (error != null) { logger.Error(error.Message); } else { logger.Info(message); } }
public OHMProvider(INLogger logger) { this.Logger = logger; this.Computer = new Computer(); this.Computer.CPUEnabled = true; this.Computer.RAMEnabled = true; this.Computer.HDDEnabled = true; this.Computer.GPUEnabled = true; this.Computer.MainboardEnabled = true; this.Computer.Open(); }
public void ErrorMessageIsLogged() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var pipelineHelper = TestSetup.SetupPipelineHelper(logger: _logger); // Act pipelineHelper.LogError(new Exception()); // Assert _logger.Received(1).Error(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); }
public SystemMonitorDataBuilder( INLogger logger, IHardwareStaticBuilder hardwareStaticBuilder, IHardwareStaticAnalyzer hardwareStaticAnalyzer, IHardwareDynamicBuilder hardwareDynamicBuilder, ISoftwareStaticBuilder softwareStaticBuilder, ISoftwareDynamicBuilder softwareDynamicBuilder) { this.Logger = logger; this.HardwareStaticBuilder = hardwareStaticBuilder; this.HardwareStaticAnalyzer = hardwareStaticAnalyzer; this.HardwareDynamicBuilder = hardwareDynamicBuilder; this.SoftwareStaticBuilder = softwareStaticBuilder; this.SoftwareDynamicBuilder = softwareDynamicBuilder; }
public void ErrorResponseMessageIsLoggedAndSuppliedErrorCodeReturnedToUser() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var pipelineHelper = TestSetup.SetupPipelineHelper(logger: _logger); // Act var actual = pipelineHelper.BuildErrorResponse(ErrorCode.CORRELATIONID_REQUIRED.ToString()); var actualPayload = Utils.ResponseToJObject(actual); // Assert _logger.Received(1).Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); Assert.AreEqual(1, actualPayload["Errors"].ToList().Count); Assert.AreEqual(ErrorCode.CORRELATIONID_REQUIRED.ToString(), actualPayload["Errors"].ToList()[0]["ErrorCode"]); Assert.AreEqual("CorrelationId must be passed.", actualPayload["Errors"].ToList()[0]["ErrorMessage"]); }
public void ErrorResponseMessageIsLoggedAndErrorDefaultsWhenWnexpectedMessageSupplied() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var pipelineHelper = TestSetup.SetupPipelineHelper(logger: _logger); // Act var actual = pipelineHelper.BuildErrorResponse("Something went wrong"); var actualPayload = Utils.ResponseToJObject(actual); // Assert _logger.Received(1).Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); Assert.AreEqual(1, actualPayload["Errors"].ToList().Count); Assert.AreEqual(ErrorCode.UNEXPECTED_ERROR.ToString(), actualPayload["Errors"].ToList()[0]["ErrorCode"]); Assert.AreEqual("An unexpected error has occurred. Please try again later.", actualPayload["Errors"].ToList()[0]["ErrorMessage"]); }
public void RequestMessageIsLogged() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var pipelineHelper = TestSetup.SetupPipelineHelper(logger: _logger); var requestBody = new JObject(); requestBody.Add("Batman", "Begins"); var request = Entities.GenerateNancyRequest(body: requestBody); // Act pipelineHelper.LogRequest(request); // Assert _logger.Received(1).Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); }
public void ResponseMessageIsLoggedForResponsesContainingErrors() { // Arrange INLogger _logger = Substitute.For <INLogger>(); var configSettings = new Settings { RequestCorrelationIdIsRequired = true }; var pipelineHelper = TestSetup.SetupPipelineHelper(configSettings, logger: _logger); var responseBody = JsonSerializer.ToJson(new { Batman = "Begins", Errors = new List <object> { new { ErrorCode = "ErrorCode", ErrorMessage = "ErrorMessage" } } }); var response = new Nancy.Response() { StatusCode = Nancy.HttpStatusCode.OK, Contents = stream => { using (var writer = new StreamWriter(stream)) { writer.Write(responseBody); } } }; // Act pipelineHelper.LogAndFormatResponse(response); // Assert _logger.Received(1).Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>()); Assert.AreEqual(Nancy.HttpStatusCode.BadRequest, response.StatusCode); }
public StoryController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public WMIClient(INLogger logger) { this.Logger = logger; }
public OutputHelper(INLogger logger) { this._logger = logger; }
public FriendController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public AdminController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public BaseApiController(INLogger logger) { this._logger = logger; }
public PipelineHelper(IConfigurationManager configuration, INLoggerFactory loggerFactory, ICorrelationId correlationId) { _configuration = configuration; _logger = loggerFactory.CreateLogger <Bootstrapper>(); _correlationId = correlationId; }
public DatabaseManager(IRolesService rolesService, INLogger logger) { this.rolesService = rolesService; this.logger = logger; }
public ConnectionController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public GuestsController(INLogger logger, IGuestRepository guestRepository) : base(logger) { _guestRepository = guestRepository; }
public static PipelineHelper SetupPipelineHelper(Settings settingsMock = null, INLogger logger = null, IConfigurationManager configurationManager = null, ICorrelationId correlationId = null) { Nancy.Json.JsonSettings.RetainCasing = true; configurationManager = configurationManager != null ? configurationManager : Substitute.For <IConfigurationManager>(); logger = logger != null ? logger : Substitute.For <INLogger>(); correlationId = correlationId != null ? correlationId : Substitute.For <ICorrelationId>(); settingsMock = settingsMock != null ? settingsMock : Entities.GetSettingsMockData(); logger.When(x => x.Trace(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>())).DoNotCallBase(); logger.When(x => x.Error(Arg.Any <string>(), Arg.Any <Exception>(), Arg.Any <Guid>())).DoNotCallBase(); configurationManager.Instance.Returns(settingsMock); return(new PipelineHelper(configurationManager, logger, correlationId)); }
public GroupManagerController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public MessengerController(IMediator mediator, INLogger logger) { this.mediator = mediator; this.logger = logger; }
public HomeController(INLogger logger) { this.logger = logger; }
public CommentController(IMediator mediator, INLogger logger) : base(mediator, logger) { }
public PipelineHelper(IConfigurationManager configuration, INLogger logger, ICorrelationId correlationId) { _configuration = configuration; _logger = logger; _correlationId = correlationId; }
public DataLoadController(INLogger logger, IDataLoadRepository repo) : base(logger) { this._repo = repo; }
public LogsHostedService(INLogger logger, IServiceProvider services) : base(logger, services) { TimeInterval = Constants.ServerHostedServiceTimeInMinutes; }
public SoftwareDynamicProvider(INLogger logger, IWin32APIClient win32APIClient) { this.Logger = logger; this.Win32APIClient = win32APIClient; }
public SocialController(IMediator mediator, INLogger logger) { this.mediator = mediator; this.logger = logger; }
public ApiBaseController(INLogger logger) { Logger = logger; }
public Builder Logger(INLogger logger) { client.Logger = logger; client.transport.Logger = logger; return(this); }