public void CanCollectLogFiles()
        {
            var fileCollector = default(FileCollector);
            var logger = default(TestLogger);
            var filePath = default(string);

            "Given I am collecting performance counter data"
                .Context(() =>
                        {
                            logger = new TestLogger();

                            filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFile.txt");

                            var fileElement = new FileElement();
                            fileElement.Name = filePath;

                            var fileConfiguration = new LogFileConfiguration();
                            fileConfiguration.Files.Add(fileElement);

                            fileCollector = new FileCollector(fileConfiguration);
                        });
            "When I begin collecting".Do(() =>
            {
                fileCollector.Collect(logger);

                File.WriteAllLines(filePath, new string[] { "This is a test"});

                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));
                File.Delete(filePath);
            });
            "The file content will be collected".Observation(() => logger.LogItems[0].Message.Should().Be("This is a test"));
        }
        public void CanLogPerformanceData()
        {
            var counterCollector = default(PerformanceCounterCollector);
            var logger = default(TestLogger);
            var totalOperations = default(PerformanceCounter);

            "Given I am collecting performance counter data"
                .Context(() =>
                        {
                            if(PerformanceCounterCategory.Exists("TestCategory"))
                                PerformanceCounterCategory.Delete("TestCategory");

                            var counters = new CounterCreationDataCollection();
                            var totalOps = new CounterCreationData();
                            totalOps.CounterName = "# operations executed";
                            totalOps.CounterHelp = "Total number of operations executed";
                            totalOps.CounterType = PerformanceCounterType.NumberOfItems32;
                            counters.Add(totalOps);
                            PerformanceCounterCategory.Create("TestCategory", "Test category", PerformanceCounterCategoryType.SingleInstance, counters);

                            totalOperations = new PerformanceCounter();
                            totalOperations.CategoryName = "TestCategory";
                            totalOperations.CounterName = "# operations executed";
                            totalOperations.MachineName = ".";
                            totalOperations.ReadOnly = false;

                            logger = new TestLogger();

                            var counter = new PerformanceCounterElement();
                            counter.Name = "# operations executed";

                            var category = new PerformanceCounterCategoryElement();
                            category.Name = "TestCategory";
                            category.PerformanceCounters.Add(counter);

                            var collectorConfiguration = new CounterConfiguration();
                            collectorConfiguration.Categories.Add(category);
                            collectorConfiguration.CollectionFrequency = "1";

                            counterCollector = new PerformanceCounterCollector(collectorConfiguration);
                        });
            "When I begin collecting".Do(() =>
                        {
                            counterCollector.Collect(logger);
                            totalOperations.IncrementBy(20);
                            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));

                            counterCollector.Dispose();
                            PerformanceCounterCategory.Delete("TestCategory");
                        });
            "Performance data will be collected".Observation(() => logger.LogItems[0].Data["Value"].ToString().Should().Be("20"));

            "The performance category will be collected".Observation(() => logger.LogItems[0].Data["CategoryName"].Should().Be("TestCategory"));

            "The performance counter name will be collected".Observation(() => logger.LogItems[0].Data["CounterName"].Should().Be("# operations executed"));
        }
        public void CanLogEventLogs()
        {
            var eventLogCollector = default(EventLogCollector);
            var logger = default(TestLogger);
            var testlog = default(EventLog);

            "Given I am collecting performance counter data"
                .Context(() =>
                {
                    if (EventLog.SourceExists("TestEventSource"))
                        EventLog.DeleteEventSource("TestEventSource");

                    EventLog.CreateEventSource("TestEventSource", "TestEventLog");
                    testlog = new EventLog("TestEventLog", ".", "TestEventSource");
                    logger = new TestLogger();

                    var logElement = new EventLogElement();
                    logElement.Name = "TestEventLog";

                    var eventLogConfiguration = new EventLogConfiguration();
                    eventLogConfiguration.EventLogs.Add(logElement);

                    eventLogCollector = new EventLogCollector(eventLogConfiguration);
                });
            "When I begin collecting".Do(() =>
            {
                eventLogCollector.Collect(logger);
                testlog.WriteEntry("This is a test", EventLogEntryType.Information);

                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2));

                eventLogCollector.Dispose();
                EventLog.DeleteEventSource("TestEventSource");
            });

            "The event log item will be collected".Observation(() => logger.LogItems[0].Message.Should().Be("This is a test"));
        }