Amazon.KinesisTap.Windows.Test/EventLogTest.cs
/// <summary>
/// Test if the EventLogSource is required
/// </summary>
Test if the EventLogSource is required
Test if the EventLogSource is required
[Theory]
        [InlineData("NonExisting")]
        [InlineData("NonExistingNotRequired")]
        public void TestRequired(string sourceId)
        {
            var config = TestUtility.GetConfig("Sources", sourceId);
            string logName = config["LogName"];
            string requiredSetting = config["Required"];
            bool required = string.IsNullOrWhiteSpace(requiredSetting) ?
                true : bool.Parse(requiredSetting);
            MemoryLogger logger = new MemoryLogger(null);
            using (EventLogSource source = new EventLogSource(logName, null, new PluginContext(config, logger, null)))
            {
                source.Start();
                System.Threading.Thread.Sleep(1000);
                if (required)
                {
                    Assert.NotEmpty(logger.Entries.Where(e => e.Contains("error")));
                }
                else
                {
                    Assert.Empty(logger.Entries.Where(e => e.Contains("error")));
                }
            }
        }
[ Theory ] [ InlineData ( " " ) ] [ InlineData ( " " ) ] public void TestRequired ( string sourceId ) { var config = TestUtility . GetConfig ( " " , sourceId ) ; string logName = config [ " " ] ; string requiredSetting = config [ " " ] ; bool required = string . IsNullOrWhiteSpace ( requiredSetting ) ? true : bool . Parse ( requiredSetting ) ; MemoryLogger logger = new MemoryLogger ( null ) ; using ( EventLogSource source = new EventLogSource ( logName , null , new PluginContext ( config , logger , null ) ) ) { source . Start ( ) ; System . Threading . Thread . Sleep ( 1000 ) ; if ( required ) { Assert . NotEmpty ( logger . Entries . Where ( e => e . Contains ( " " ) ) ) ; } else { Assert . Empty ( logger . Entries . Where ( e => e . Contains ( " " ) ) ) ; } } }
Test if the EventLogSource is required
Test if the EventLogSource is required
sourceId
string