private static ILoggingConfig GetLogConfig(IConfigData configData)
        {
            var data      = configData.GetString(LOGGING_BLACKLIST_SOURCES_KEY);
            var values    = data.Replace(";", ",").Replace(":", ".").Split(",");
            var blacklist = new HashSet <string>();

            foreach (var k in values)
            {
                blacklist.Add(k);
            }

            data   = configData.GetString(LOGGING_WHITELIST_SOURCES_KEY);
            values = data.Replace(";", ",").Replace(":", ".").Split(",");
            var whitelist = new HashSet <string>();

            foreach (var k in values)
            {
                blacklist.Add(k);
            }

            Enum.TryParse(configData.GetString(LOGGING_LOGLEVEL_KEY, Services.Diagnostics.LoggingConfig.DEFAULT_LOGLEVEL.ToString()), true, out LogLevel logLevel);
            var result = new LoggingConfig
            {
                LogLevel             = logLevel,
                BwListPrefix         = configData.GetString(LOGGING_BLACKLIST_PREFIX_KEY),
                BlackList            = blacklist,
                WhiteList            = whitelist,
                DateFormat           = configData.GetString(LOGGING_DATEFORMAT_KEY, Services.Diagnostics.LoggingConfig.DEFAULT_DATE_FORMAT),
                LogProcessId         = configData.GetBool(LOGGING_INCLUDEPROCESSID_KEY, true),
                ExtraDiagnostics     = configData.GetBool(LOGGING_EXTRADIAGNOSTICS_KEY, false),
                ExtraDiagnosticsPath = configData.GetString(LOGGING_EXTRADIAGNOSTICSPATH_KEY)
            };

            return(result);
        }
Beispiel #2
0
        public void SoftAssertIsFalseTest()
        {
            SoftAssert softAssert = new SoftAssert(new FileLogger(LoggingConfig.GetLogDirectory(), "UnitTests.SoftAssertUnitTests.SoftAssertIsFalseTest", MessageType.GENERIC, true));

            softAssert.IsFalse(2 == 1, "Test");
            softAssert.FailTestIfAssertFailed();
        }
        private static RedisTarget _redisTarget; // Required to ensure assembly is copied to output.
#pragma warning restore CS0169

        protected void Application_Start()
        {
            LoggingConfig.ConfigureLogging();

            TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("InstrumentationKey");

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ModelBinders.Binders.Add(typeof(string), new TrimStringModelBinder());

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

            var container = StructuremapMvc.StructureMapDependencyScope.Container;

            FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = new StructureMapValidatorFactory(container));

            WebMessageBuilders.Register();
            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;

            AuditMessageFactory.RegisterBuilder(message =>
            {
                message.Source = new Source
                {
                    Component = "EAS-Web",
                    System    = "EAS",
                    Version   = typeof(MvcApplication).Assembly.GetName().Version.ToString()
                };
            });
        }
Beispiel #4
0
        internal RootConfig()
        {
            Logging  = new LoggingConfig();
            DynamoDB = new DynamoDBConfig();
            S3       = new S3Config();
            EC2      = new EC2Config();
            Proxy    = new ProxyConfig();

            EndpointDefinition = AWSConfigs._endpointDefinition;
            Region             = AWSConfigs._awsRegion;
            ProfileName        = AWSConfigs._awsProfileName;
            ProfilesLocation   = AWSConfigs._awsAccountsLocation;

        #if !WIN_RT && !WINDOWS_PHONE
            //var root = AWSConfigs.GetSection<AWSSection>(_rootAwsSectionName);

//	            Logging.Configure(root.Logging);
//	            DynamoDB.Configure(root.DynamoDB);
//	            S3.Configure(root.S3);
//	            EC2.Configure(root.EC2);
//	            Proxy.Configure(root.Proxy);
//
//	            EndpointDefinition = Choose(EndpointDefinition, root.EndpointDefinition);
//	            Region = Choose(Region, root.Region);
//	            ProfileName = Choose(ProfileName, root.ProfileName);
//	            ProfilesLocation = Choose(ProfilesLocation, root.ProfilesLocation);
        #endif
        }
        public void Init()
        {
            Directory.CreateDirectory(_tempDirectory);

            _configManager = new RuntimeConfigManager()
            {
                ConfigDirectory = _tempDirectory
            };

            var config = new LoggingConfig()
            {
                LoggerConfigs = new List <ModuleLoggerConfig>()
                {
                    new ModuleLoggerConfig()
                    {
                        LoggerName = "Test"
                    }
                }
            };

            _configManager.SaveConfiguration(config);
            _management = new ServerLoggerManagement()
            {
                ConfigManager = _configManager
            };

            _host = new ModuleManager()
            {
                ConfigManager    = _configManager,
                LoggerManagement = _management
            };
            _management.ActivateLogging(_host);
        }
Beispiel #6
0
        /// <summary>
        /// To capture a screenshot during execution
        /// </summary>
        /// <param name="webDriver">The WebDriver</param>
        /// <param name="log">The logger being used</param>
        /// <param name="appendName">Appends a name to the end of a filename</param>
        /// <returns>Boolean if the save of the image was successful</returns>
        /// <example>
        /// <code source = "../SeleniumUnitTesting/SeleniumUnitTest.cs" region="CaptureScreenshot" lang="C#" />
        /// </example>
        public static bool CaptureScreenshot(this IWebDriver webDriver, Logger log, string appendName = "")
        {
            try
            {
                string path = string.Empty;

                // Check if we are using a file logger
                if (!(log is FileLogger))
                {
                    // Since this is not a file logger we will need to use a generic file name
                    path = CaptureScreenshot(webDriver, LoggingConfig.GetLogDirectory(), "ScreenCap" + appendName, GetScreenShotFormat());
                }
                else
                {
                    // Calculate the file name
                    string fullpath  = ((FileLogger)log).FilePath;
                    string directory = Path.GetDirectoryName(fullpath);
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullpath) + appendName;
                    path = CaptureScreenshot(webDriver, directory, fileNameWithoutExtension, GetScreenShotFormat());
                }

                log.LogMessage(MessageType.INFORMATION, "Screenshot saved: " + path);
                return(true);
            }
            catch (Exception exception)
            {
                log.LogMessage(MessageType.ERROR, "Screenshot error: {0}", exception.ToString());
                return(false);
            }
        }
Beispiel #7
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            HttpConfiguration config = new HttpConfiguration();

            config
            .EnableSwagger(c =>
            {
                //Name of the API
                c.SingleApiVersion("v1", "Fusion Configuration API");

                /**
                 * Make sure the project Honeywell.GLSS.Tools.WebAPI have XML document option enabled
                 * and the file Honeywell.GLSS.Tools.WebAPI.xml is available in BaseDirectory. Otherwise
                 * Swagger Ui will not show any documentation.
                 */
                c.IncludeXmlComments(string.Format(@"{0}\Honeywell.GLSS.Tools.WebAPI.xml",
                                                   System.AppDomain.CurrentDomain.BaseDirectory));
                c.PrettyPrint();
            })
            .EnableSwaggerUi();


            WebApiConfig.Register(config);
            DryIocConfig.Configure(config);
            LoggingConfig.Configure();
            app.UseWebApi(config);
        }
        protected void Application_Start()
        {
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
            AntiForgeryConfig.RequireSsl = true;
            AreaRegistration.RegisterAllAreas();
            BinderConfig.RegisterBinders(ModelBinders.Binders);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            LoggingConfig.ConfigureLogging();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["InstrumentationKey"];
            WebMessageBuilders.Register();
            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;

            AuditMessageFactory.RegisterBuilder(m =>
            {
                m.Source = new Source
                {
                    Component = "EmployerAccounts-Web",
                    System    = "EmployerAccounts",
                    Version   = typeof(MvcApplication).Assembly.GetName().Version.ToString()
                };
            });

            if (ConfigurationHelper.IsEnvironmentAnyOf(Environment.Local, Environment.At, Environment.Test))
            {
                SystemDetailsViewModel.EnvironmentName = ConfigurationHelper.CurrentEnvironment.ToString();
                SystemDetailsViewModel.VersionNumber   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }

            StartServiceBusEndpoint();
        }
Beispiel #9
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration httpConfig = new HttpConfiguration();

            UnityConfig.Register(httpConfig);

            ConfigureAuth(app);

            //enable CORS policy
            app.Map("/signalr", map =>
            {
                // Setup the CORS middleware to run before SignalR.
                // By default this will allow all origins.
                map.UseCors(CorsOptions.AllowAll);
                map.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()
                {
                    Provider = new QueryStringOAuthBearerProvider()
                });
                var hubConfiguration = new HubConfiguration
                {
                    Resolver = GlobalHost.DependencyResolver
                };
                map.RunSignalR(hubConfiguration);
            });

            WebApiConfig.Register(httpConfig);

            app.UseWebApi(httpConfig);

            //config logging system
            LoggingConfig.LogToDb();

            //config automapper for the solution
            DtoMapping.Map();
        }
Beispiel #10
0
        public RootConfig()
        {
            Logging             = new LoggingConfig();
            Proxy               = new ProxyConfig();
            EndpointDefinition  = AWSConfigs._endpointDefinition;
            Region              = AWSConfigs._awsRegion;
            ProfileName         = AWSConfigs._awsProfileName;
            ProfilesLocation    = AWSConfigs._awsAccountsLocation;
            UseSdkCache         = AWSConfigs._useSdkCache;
            CorrectForClockSkew = true;
            AWSSection section = AWSConfigs.GetSection <AWSSection>("aws");

            Logging.Configure(section.Logging);
            Proxy.Configure(section.Proxy);
            ServiceSections = section.ServiceSections;
            if (section.UseSdkCache.HasValue)
            {
                UseSdkCache = section.UseSdkCache.Value;
            }
            EndpointDefinition = Choose(EndpointDefinition, section.EndpointDefinition);
            Region             = Choose(Region, section.Region);
            ProfileName        = Choose(ProfileName, section.ProfileName);
            ProfilesLocation   = Choose(ProfilesLocation, section.ProfilesLocation);
            ApplicationName    = Choose(ApplicationName, section.ApplicationName);
            if (section.CorrectForClockSkew.HasValue)
            {
                CorrectForClockSkew = section.CorrectForClockSkew.Value;
            }
        }
Beispiel #11
0
        public static void Main(string[] args)
        {
            var resourceLocator = new ConsoleAppResourceLocator();
            var log             = new LoggingConfig(resourceLocator).CreateRootLogWriter();

            log.Debug("start");

            var options = new Options(args);

            var _htmlToEpub = new HtmlToEpubConverter(
                new Counter(log),
                log,
                options,
                new MecabParser(),
                new MecabReader(),
                new MecabBackend(),
                new XHtmlMaker(),
                new JmdicFastReader(
                    log,
                    resourceLocator,
                    new Jmdictionary()
                    ),
                new ContentsBreaker(new ChapterMarkersProvider(options, new ContentsDetector())),
                new EpubMaker(log, options, resourceLocator),
                new SentenceBreaker()
                );

            options.Print(Console.Out);

            _htmlToEpub.Convert().ContinueWith(_ =>
            {
                log.Debug("end");
            }).Wait();
        }
Beispiel #12
0
        public RootConfig()
        {
            Logging = new LoggingConfig();
            Proxy   = new ProxyConfig();

            EndpointDefinition  = AWSConfigs._endpointDefinition;
            Region              = AWSConfigs._awsRegion;
            ProfileName         = AWSConfigs._awsProfileName;
            ProfilesLocation    = AWSConfigs._awsAccountsLocation;
            UseSdkCache         = AWSConfigs._useSdkCache;
            CorrectForClockSkew = true;

#if !WIN_RT && !WINDOWS_PHONE
            var root = AWSConfigs.GetSection <AWSSection>(_rootAwsSectionName);

            Logging.Configure(root.Logging);
            Proxy.Configure(root.Proxy);

            ServiceSections = root.ServiceSections;
            if (root.UseSdkCache.HasValue)
            {
                UseSdkCache = root.UseSdkCache.Value;
            }

            EndpointDefinition = Choose(EndpointDefinition, root.EndpointDefinition);
            Region             = Choose(Region, root.Region);
            ProfileName        = Choose(ProfileName, root.ProfileName);
            ProfilesLocation   = Choose(ProfilesLocation, root.ProfilesLocation);
            if (root.CorrectForClockSkew.HasValue)
            {
                CorrectForClockSkew = root.CorrectForClockSkew.Value;
            }
#endif
        }
Beispiel #13
0
        /// <summary>
        /// Create a logger
        /// </summary>
        /// <returns>A logger</returns>
        protected Logger CreateLogger()
        {
            this.LoggedExceptionList   = new List <string>();
            this.LoggingEnabledSetting = LoggingConfig.GetLoggingEnabledSetting();

            // Setup the exception listener
            AppDomain currentDomain = AppDomain.CurrentDomain;

            if (LoggingConfig.GetFirstChanceHandler())
            {
                currentDomain.FirstChanceException += this.FirstChanceHandler;
            }

            if (this.LoggingEnabledSetting != LoggingEnabled.NO)
            {
                return(LoggingConfig.GetLogger(
                           StringProcessor.SafeFormatter(
                               "{0} - {1}",
                               this.GetFullyQualifiedTestClassName(),
                               DateTime.UtcNow.ToString("yyyy-MM-dd-hh-mm-ss-ffff", CultureInfo.InvariantCulture))));
            }
            else
            {
                return(new ConsoleLogger());
            }
        }
        public void WritesScopeMessagesUsingFormatter(string?sensitiveValue, string state, string expected)
        {
            var logLevel     = LogLevel.Error;
            var eventId      = Model.Create <EventId>();
            var message      = Guid.NewGuid().ToString();
            var categoryName = Guid.NewGuid().ToString();

            string Formatter(string logState, Exception?error) => message;

            var config = new LoggingConfig();

            if (sensitiveValue != null)
            {
                config.SensitiveValues.Add(sensitiveValue);
            }

            var output = Substitute.For <ITestOutputHelper>();

            var sut = new TestOutputLogger(categoryName, output, config);

            using (sut.BeginScope(state))
            {
                sut.Log(logLevel, eventId, state, null, Formatter);
            }

            output.Received().WriteLine($"<Scope: {expected}>");
            output.Received().WriteLine($"   {logLevel} [{eventId.Id}]: {message}");
            output.Received().WriteLine($"</Scope: {expected}>");
        }
Beispiel #15
0
 /// <summary>
 /// Validates the <see cref="LoggingConfig"/>.
 /// </summary>
 /// <param name="loggingConfig">The <see cref="LoggingConfig"/>.</param>
 private void ValidateLogging(LoggingConfig loggingConfig)
 {
     if (loggingConfig == null)
     {
         throw new Saml20ConfigurationException("Configuration Logging cannot be null");
     }
 }
Beispiel #16
0
        public new void Setup()
        {
            // Do base generic setup
            base.Setup();

            try
            {
                // Only use event firing if we are logging
                if (LoggingConfig.GetLoggingEnabledSetting() != LoggingEnabled.NO)
                {
                    this.SetupEventFiringTester();
                }
                else
                {
                    this.SetupNoneEventFiringTester();
                }
            }
            catch (Exception e)
            {
                this.TryToLog(MessageType.ERROR, "Setup failed because: {0}\r\n{1}", e.Message, e.StackTrace);

                // Make sure we do the standard teardown
                this.Teardown();
                throw e;
            }

            this.PostSetupLogging();
        }
Beispiel #17
0
 static void Main()
 {
     LoggingConfig.Initialize();
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new Alarm());
 }
Beispiel #18
0
        public void Configuration(IAppBuilder app)
        {
            // make sure we're logging
            log4net.Config.XmlConfigurator.Configure();

            // configure http
            HttpConfiguration httpConfig = new HttpConfiguration();

            // add the filters (e.g. requiring https)
            FilterConfig.RegisterHttpFilters(httpConfig.Filters);

            // add the handlers (e.g. logging and exception handling)
            LoggingConfig.RegisterHandlers(httpConfig.Services);

            WebSecurity.InitializeDatabaseConnection("ProviderPortalConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true);

            UnityConfig.RegisterComponents(httpConfig);

            ConfigureOAuth(app, (ISettingsProvider)httpConfig.DependencyResolver.GetService(typeof(ISettingsProvider)));

            ConfigureWebApi(httpConfig);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseWebApi(httpConfig);
        }
Beispiel #19
0
        /// <summary>
        /// To capture a page source during execution
        /// </summary>
        /// <param name="webDriver">The WebDriver</param>
        /// <param name="testObject">The TestObject to associate the file with</param>
        /// <param name="appendName">Appends a name to the end of a filename</param>
        /// <returns>Boolean if the save of the page source was successful</returns>
        public static bool SavePageSource(this IWebDriver webDriver, ISeleniumTestObject testObject, string appendName = "")
        {
            try
            {
                string path = string.Empty;

                // Check if we are using a file logger
                if (testObject.Log is IFileLogger logger)
                {
                    // Calculate the file name
                    string fullpath  = logger.FilePath;
                    string directory = Path.GetDirectoryName(fullpath);
                    string fileNameWithoutExtension = $"{Path.GetFileNameWithoutExtension(fullpath)}_PS{ appendName}";

                    path = SavePageSource(webDriver, testObject, directory, fileNameWithoutExtension);
                }
                else
                {
                    // Since this is not a file logger we will need to use a generic file name
                    path = SavePageSource(webDriver, testObject, LoggingConfig.GetLogDirectory(), $"PageSource{appendName}");
                }

                testObject.Log.LogMessage(MessageType.INFORMATION, $"Page Source saved: {path}");
                return(true);
            }
            catch (Exception exception)
            {
                testObject.Log.LogMessage(MessageType.ERROR, $"Page Source error: {exception}");
                return(false);
            }
        }
Beispiel #20
0
        public RootConfig()
        {
            Logging = new LoggingConfig();
            Proxy = new ProxyConfig();

            EndpointDefinition = AWSConfigs._endpointDefinition;
            Region = AWSConfigs._awsRegion;
            ProfileName = AWSConfigs._awsProfileName;
            ProfilesLocation = AWSConfigs._awsAccountsLocation;
            UseSdkCache = AWSConfigs._useSdkCache;
            CorrectForClockSkew = true;

#if !PCL
            var root = AWSConfigs.GetSection<AWSSection>(_rootAwsSectionName);

            Logging.Configure(root.Logging);
            Proxy.Configure(root.Proxy);

            ServiceSections = root.ServiceSections;
            if (root.UseSdkCache.HasValue)
                UseSdkCache = root.UseSdkCache.Value;

            EndpointDefinition = Choose(EndpointDefinition, root.EndpointDefinition);
            Region = Choose(Region, root.Region);
            ProfileName = Choose(ProfileName, root.ProfileName);
            ProfilesLocation = Choose(ProfilesLocation, root.ProfilesLocation);
            ApplicationName = Choose(ApplicationName, root.ApplicationName);
            if (root.CorrectForClockSkew.HasValue)
                CorrectForClockSkew = root.CorrectForClockSkew.Value;
#endif
        }
Beispiel #21
0
        /// <summary>
        /// Capture a screenshot during execution and associate to the testObject
        /// </summary>
        /// <param name="webDriver">The WebDriver</param>
        /// <param name="testObject">The test object to associate and log to</param>
        /// <param name="appendName">Appends a name to the end of a filename</param>
        /// <returns>Boolean if the save of the image was successful</returns>
        public static bool CaptureScreenshot(this IWebDriver webDriver, ISeleniumTestObject testObject, string appendName = "")
        {
            try
            {
                string path = string.Empty;

                if (testObject.Log is IHtmlFileLogger htmlLogger)
                {
                    htmlLogger.EmbedImage(((ITakesScreenshot)webDriver).GetScreenshot().AsBase64EncodedString);
                }
                else if (testObject.Log is IFileLogger fileLogger)
                {
                    // Calculate the file name
                    string fullpath  = fileLogger.FilePath;
                    string directory = Path.GetDirectoryName(fullpath);
                    string fileNameWithoutExtension = $"{Path.GetFileNameWithoutExtension(fullpath)}{appendName}";
                    path = CaptureScreenshot(webDriver, testObject, directory, fileNameWithoutExtension, GetScreenShotFormat());
                }
                else
                {
                    // Since this is not a file logger we will need to use a generic file name
                    path = CaptureScreenshot(webDriver, testObject, LoggingConfig.GetLogDirectory(), $"ScreenCap{appendName}", GetScreenShotFormat());
                }

                testObject.Log.LogMessage(MessageType.INFORMATION, $"Screenshot saved: {path}");
                return(true);
            }
            catch (Exception exception)
            {
                testObject.Log.LogMessage(MessageType.ERROR, $"Screenshot error: {exception}");
                return(false);
            }
        }
Beispiel #22
0
        public void InitPjsua(UaConfig uaCfg, LoggingConfig logCfg, MediaConfig mediaCfg)
        {
            var ua_cfg = _mapper.Map(uaCfg, _uaCfg);
            var l_cfg  = _mapper.Map(logCfg, _lCfg);

            ua_cfg.cb.on_reg_state = OnRegState;

            ua_cfg.cb.on_call_state            = OnCallState;
            ua_cfg.cb.on_call_media_state      = OnCallMediaState;
            ua_cfg.cb.on_incoming_call         = OnIncomingCall;
            ua_cfg.cb.on_stream_destroyed      = OnStreamDestroyed;
            ua_cfg.cb.on_dtmf_digit            = OnDtmfDigit;
            ua_cfg.cb.on_call_transfer_request = OnCallTransfer;
            ua_cfg.cb.on_call_transfer_status  = OnCallTransferStatus;
            ua_cfg.cb.on_call_redirected       = OnCallRedirect;

            ua_cfg.cb.on_nat_detect = OnNatDetect;

            ua_cfg.cb.on_buddy_state        = OnBuddyState;
            ua_cfg.cb.on_incoming_subscribe = OnIncomingSubscribe;
            ua_cfg.cb.on_pager        = OnPager;
            ua_cfg.cb.on_pager_status = OnPagerStatus;
            ua_cfg.cb.on_typing       = OnTyping;

            l_cfg.AnonymousMember1 = OnLog;

            //etc;
            _mCfg = new pjsua_media_config();
            PJSUA_DLL.Media.pjsua_media_config_default(_mCfg);
            Helper.GuardError(PJSUA_DLL.Basic.pjsua_init(ua_cfg, l_cfg, _mapper.Map(mediaCfg, _mCfg)));
        }
Beispiel #23
0
        public void HomePageWithComplexReport()
        {
            string reportPath = Path.Combine(LoggingConfig.GetLogDirectory(), "HomePageWithComplexReport.html");
            string rawResults = Path.Combine(LoggingConfig.GetLogDirectory(), "HomePageWithComplexReport.json");

            // Get to home page
            LoginPageModel page = new LoginPageModel(this.TestObject);

            page.OpenLoginPage();
            page.LoginWithValidCredentials(Config.GetGeneralValue("User"), Config.GetGeneralValue("Pass"));

            // Setup custom rules
            AxeBuilder builder = new AxeBuilder(WebDriver)
                                 .Exclude("#HomePage")
                                 .WithOutputFile(rawResults)
                                 .DisableRules("landmark-one-main", "page-has-heading-one");

            // Reprot
            WebDriver.CreateAxeHtmlReport(builder.Analyze(), reportPath);

            // Check if there were any violations
            if (!File.ReadAllText(reportPath).Contains("Violation: 0"))
            {
                TestObject.AddAssociatedFile(reportPath);
                TestObject.AddAssociatedFile(rawResults);
                Assert.Fail($"Failed violation check see {reportPath} for more details.");
            }
        }
Beispiel #24
0
 protected void Application_Start()
 {
     LoggingConfig.InitLogging();
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
Beispiel #25
0
 public AppConfig()
 {
     Azure    = new AzureConfig();
     Database = new DatabaseConfig();
     Logging  = new LoggingConfig();
     Cache    = new CacheConfig();
 }
Beispiel #26
0
        /// <summary>
        /// To capture a page source during execution
        /// </summary>
        /// <param name="appiumDriver">The AppiumDriver</param>
        /// <param name="testObject">The TestObject to associate the file and log with</param>
        /// <param name="appendName">Appends a name to the end of a filename</param>
        /// <returns>Boolean if the save of the page source was successful</returns>
        public static bool SavePageSource(this AppiumDriver <IWebElement> appiumDriver, AppiumTestObject testObject, string appendName = "")
        {
            try
            {
                string path = string.Empty;

                // Check if we are using a file logger
                if (!(testObject.Log is FileLogger))
                {
                    // Since this is not a file logger we will need to use a generic file name
                    path = SavePageSource(appiumDriver, testObject, LoggingConfig.GetLogDirectory(), "PageSource" + appendName);
                }
                else
                {
                    // Calculate the file name
                    string fullpath  = ((FileLogger)testObject.Log).FilePath;
                    string directory = Path.GetDirectoryName(fullpath);
                    string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fullpath) + "_PS" + appendName;

                    path = SavePageSource(appiumDriver, testObject, directory, fileNameWithoutExtension);
                }

                testObject.Log.LogMessage(MessageType.INFORMATION, "Page Source saved: " + path);
                return(true);
            }
            catch (Exception exception)
            {
                testObject.Log.LogMessage(MessageType.ERROR, "Page Source error: {0}", exception.ToString());
                return(false);
            }
        }
Beispiel #27
0
        public void FormatHidesSensitiveDataInException(string?sensitiveValue, string message, string expected)
        {
            var config       = new LoggingConfig();
            var scopeLevel   = 1;
            var categoryName = Guid.NewGuid().ToString();
            var logLevel     = LogLevel.Information;
            var eventId      = Model.Create <EventId>();
            var logMessage   = Guid.NewGuid().ToString();
            var exception    = new InvalidOperationException(message);

            if (sensitiveValue != null)
            {
                config.SensitiveValues.Add(sensitiveValue);
            }

            var sut = new DefaultFormatter(config);

            var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, logMessage, exception);

            actual.Should().Contain(expected);

            if (sensitiveValue != null)
            {
                actual.Should().NotContain(sensitiveValue);
            }
        }
Beispiel #28
0
        public void PerfTimerCollectionFilesAreAddedToAssociatedFiles()
        {
            // get log path
            string logFilePath = ((IFileLogger)this.Log).FilePath;

            this.PerfTimerCollection.StartTimer("testTimer");
            this.PerfTimerCollection.StopTimer("testTimer");
            this.PerfTimerCollection.Write(this.Log);

            string perfTimerLogPath = Path.Combine(LoggingConfig.GetLogDirectory(), this.PerfTimerCollection.FileName);

            this.Teardown();

            // test that performance timer file path is written to the log
            using (StreamReader sr = File.OpenText(logFilePath))
            {
                string[] lines = File.ReadAllLines(logFilePath);
                for (int x = 0; x < lines.Length - 1; x++)
                {
                    if (lines[x] == "GENERIC:\tList of Associated Files: ")
                    {
                        Assert.AreEqual(perfTimerLogPath, lines[x + 1]);
                    }
                }
            }
        }
Beispiel #29
0
        public void FormatReturnsValueWithPadding(int scopeLevel)
        {
            var config       = new LoggingConfig();
            var padding      = new string(' ', config.ScopePaddingSpaces *scopeLevel);
            var categoryName = Guid.NewGuid().ToString();
            var logLevel     = LogLevel.Information;
            var eventId      = Model.Create <EventId>();
            var message      = Guid.NewGuid().ToString();
            var exception    = new ArgumentNullException(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());

            var sut = new DefaultFormatter(config);

            var actual = sut.Format(scopeLevel, categoryName, logLevel, eventId, message, exception);

            _output.WriteLine(actual);

            if (scopeLevel > 0)
            {
                actual.Should().StartWith(padding);
            }
            else
            {
                actual.Should().NotStartWith(" ");
            }
        }
Beispiel #30
0
        public void AcceptNUnitAsserts()
        {
            SoftAssert softAssert = new SoftAssert(new FileLogger(LoggingConfig.GetLogDirectory(), "UnitTests.SoftAssertUnitTests.AcceptNUnitAsserts"));

            softAssert.Assert(() => NUnit.Framework.Assert.AreEqual("a", "a"), "1");
            softAssert.FailTestIfAssertFailed();
        }
        public void LogWritesMessageUsingSpecifiedLineFormatter()
        {
            var logLevel     = LogLevel.Error;
            var eventId      = Model.Create <EventId>();
            var state        = Guid.NewGuid().ToString();
            var message      = Guid.NewGuid().ToString();
            var exception    = new ArgumentNullException(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
            var categoryName = Guid.NewGuid().ToString();
            var expected     = Guid.NewGuid().ToString();

            string Formatter(string logState, Exception?error) => message;

            var formatter = Substitute.For <ILogFormatter>();
            var config    = new LoggingConfig {
                Formatter = formatter
            };

            formatter.Format(0, categoryName, logLevel, eventId, message, exception).Returns(expected);

            var output = Substitute.For <ITestOutputHelper>();

            var sut = new TestOutputLogger(categoryName, output, config);

            sut.Log(logLevel, eventId, state, exception, Formatter);

            formatter.Received().Format(0, categoryName, logLevel, eventId, message, exception);

            output.Received().WriteLine(expected);
        }