public void BasicConfigWrongTypeInFormatterParameterDoesNotThrow() { var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\WithWrongFormatterParameter.xml", createSinks: false); Assert.IsNotNull(svcConfiguration); }
public void EventSourceNameLeftEmpty() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\NoEventSourceName.xml")); StringAssert.Contains(exc.ToString(), "The EventSource 'name' and 'id' values are missing. Please provide either name or id."); }
public void OutProcCustomSchemaValidSchemasOutside() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\ExternalSchemaValidation.xml")); StringAssert.Contains(exc.ToString(), "The 'attr' attribute is invalid - The value 'foo' is invalid according to its datatype"); }
protected override void When() { this.sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithManyEventSourcesWithArgumentsAndFilters.xml"); }
public void SessionNameLeftEmpty() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\ConfigSessionNameEmpty.xml")); StringAssert.Contains(exc.ToString(), "The 'sessionNamePrefix' attribute is invalid - The value '' is invalid according to its datatype "); }
public void then_exception_is_thrown() { var sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithBadTypes.xml"); }
protected override void When() { this.Sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithDefaultValues.xml"); }
public void WhenUsingCustomSinkBuiltInSinksForSameSource() { string fileName1 = "multipleFlatFile.log"; File.Delete(fileName1); string fileName2 = "multipleMockFlatFile.log"; File.Delete(fileName2); var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProc.Logger; string message = string.Concat("Message ", Guid.NewGuid()); string message2 = string.Concat("Message2 ", Guid.NewGuid()); IEnumerable <string> entries = null; IEnumerable <string> entries2 = null; var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\CustomSink\\Multiple.xml"); using (TraceEventService collector = new TraceEventService(svcConfiguration)) { try { collector.Start(); logger.LogSomeMessage(message); logger.LogSomeMessage(message2); entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName1, 2, "--==--"); entries2 = FlatFileHelper.PollUntilTextEventsAreWritten(fileName2, 2, "==-=="); DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 4); } finally { collector.Stop(); } } Assert.IsTrue(File.Exists(fileName1)); Assert.AreEqual <int>(2, entries.Count()); StringAssert.Contains(entries.First().ToString(), message); StringAssert.Contains(entries.Last().ToString(), message2); Assert.IsTrue(File.Exists(fileName2)); Assert.AreEqual <int>(2, entries.Count()); StringAssert.Contains(entries.First().ToString(), message); StringAssert.Contains(entries.Last().ToString(), message2); var dt = DatabaseHelper.GetLoggedTable(validConnectionString); Assert.AreEqual(4, dt.Rows.Count); var rowsWithMessage1 = dt.Select(string.Format("Payload like '%{0}%'", message)); Assert.AreEqual(2, rowsWithMessage1.Count()); var dr = rowsWithMessage1[0]; Assert.AreEqual(4, (int)dr["Level"]); Assert.AreEqual(8, (int)dr["EventID"]); Assert.AreEqual("testingInstance", dr["InstanceName"].ToString()); StringAssert.Contains((string)dr["Payload"], message); dr = rowsWithMessage1[1]; Assert.AreEqual(4, (int)dr["Level"]); Assert.AreEqual(8, (int)dr["EventID"]); Assert.AreEqual("testingInstance", dr["InstanceName"].ToString()); StringAssert.Contains((string)dr["Payload"], message); var rowsWithMessage2 = dt.Select(string.Format("Payload like '%{0}%'", message2)); Assert.AreEqual(2, rowsWithMessage2.Count()); dr = rowsWithMessage2[0]; Assert.AreEqual(4, (int)dr["Level"]); Assert.AreEqual(8, (int)dr["EventID"]); Assert.AreEqual("testingInstance", dr["InstanceName"].ToString()); StringAssert.Contains((string)dr["Payload"], message2); dr = rowsWithMessage2[1]; Assert.AreEqual(4, (int)dr["Level"]); Assert.AreEqual(8, (int)dr["EventID"]); Assert.AreEqual("testingInstance", dr["InstanceName"].ToString()); StringAssert.Contains((string)dr["Payload"], message2); }
public void WhenNoEventSourceProperties() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\BasicConfigNoEventSourceIdentifier.xml")); StringAssert.Contains(exc.ToString(), "The EventSource 'name' and 'id' values are missing. Please provide either name or id."); }
public void WhenOnlyMandatoryProperties() { var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\RollingFlatFile\\RollingFlatFileMissingParams.xml"); Assert.IsNotNull(svcConfiguration); }
public void WhenUsingCustomSinkAndParamsAreNotInOrder() { var exc = ExceptionAssertHelper.Throws <Exception>(() => TraceEventServiceConfiguration.Load("Configurations\\CustomSink\\CustomSinkDiffOrder.xml")); StringAssert.Contains(exc.ToString(), "The parameters specified in this element does not map to an existing type member. All paramters are required in the same order of the defined type member"); }
public void WhenEmptyFileName() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\RollingFlatFile\\RollingFlatFileEmptyFileName.xml")); StringAssert.Contains(exc.ToString(), "The 'fileName' attribute is invalid - The value '' is invalid according to its datatype "); }
public void WhenNoFormatterSpecified() { var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\RollingFlatFile\\RollingFlatFileNoFormatter.xml"); Assert.IsNotNull(svcConfiguration); }
public void WhenConfigIsValidAndComplete() { var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\RollingFlatFile\\RollingFlatFile.xml"); Assert.IsNotNull(svcConfiguration); }
public void then_exception_is_thrown() { TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithNoEventSourceNameId.xml"); }
public void WhenWrongTypeForFormatter() { var svcConfiguration = TraceEventServiceConfiguration.Load("Configurations\\WithWrongFormatterParameter.xml", createSinks: false); Assert.IsNotNull(svcConfiguration); }
protected override void When() { this.Sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithManySinks.xml"); }
public void WhenUsingTwoCollectorsForSameEventSourceWithDifferentSinkTypes() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); string fileName = "TwoCollectorsSameEventSourceDifferentSinkTypes.log"; File.Delete(fileName); string header = "==========="; var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(header); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); var subject = new EventEntrySubject(); subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1); SinkSettings sinkSettings = new SinkSettings("dbSink", subject, new List <EventSourceSettings>() { { settings } }); var subject2 = new EventEntrySubject(); subject2.LogToFlatFile(fileName, formatter); SinkSettings sinkSettings2 = new SinkSettings("ffSink", subject2, new List <EventSourceSettings>() { { settings } }); System.Data.DataTable eventsDataTable = null; List <SinkSettings> sinks = new List <SinkSettings>() { sinkSettings, sinkSettings2 }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); IEnumerable <string> entries = null; using (TraceEventService collector = new TraceEventService(svcConfiguration)) using (TraceEventService collector2 = new TraceEventService(svcConfiguration)) { collector.Start(); collector2.Start(); try { for (int n = 0; n < 10; n++) { logger.LogSomeMessage("some message" + n.ToString()); } eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 10); entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 10, header); } finally { collector.Stop(); collector2.Stop(); } } Assert.AreEqual(10, eventsDataTable.Rows.Count); StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message"); Assert.AreEqual(10, entries.Count()); StringAssert.Contains(entries.First(), "some message0"); StringAssert.Contains(entries.Last(), "some message9"); }
protected override void When() { this.Sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithExtensionsNoSchemaValidation.xml"); }
public void BasicConfigAmbiguityNameIdInSource() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\BasicConfigSourceNameAndId.xml")); StringAssert.Contains(exc.ToString(), "There is an ambiguity when both name and id are specified. Specify only one value."); }
protected override void When() { this.Sut = TraceEventServiceConfiguration.Load("Etw\\Configuration\\WithEventSourceNameOnly.xml"); }
public void WhenUsingXmlFormatterWithInvalidDateTimeFormate() { var exc = ExceptionAssertHelper.Throws <ConfigurationException>(() => TraceEventServiceConfiguration.Load("Configurations\\WithFormatter\\FlatFileXmlWrongDateTime.xml")); StringAssert.Contains(exc.InnerException.Message, "The date time format is invalid."); }