public void WhenConcurrentEventsRaised() { var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); InMemorySink sink = new InMemorySink(formatter); SinkSettings sinkSettings = new SinkSettings("memorySink", sink, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); TestScenario.WithConfiguration( svcConfiguration, () => { sink.WaitSignalCondition = () => sink.EventWrittenCount == 100; for (int n = 0; n < 100; n++) { logger.LogSomeMessage("some message" + n.ToString()); } sink.WaitOnAsyncEvents.WaitOne(TimeSpan.FromSeconds(10)); }); StringAssert.Contains(sink.ToString(), "some message99"); }
public void WhenThreadId() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProcEnum.Logger; EventTextFormatter formatter = new EventTextFormatter(); System.Data.DataTable eventsDataTable = null; var subject = new EventEntrySubject(); subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", bufferingCount: 1); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProcEnum", null, EventLevel.LogAlways); SinkSettings sinkSettings = new SinkSettings("sqlDBsink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); TestScenario.WithConfiguration( svcConfiguration, () => { logger.SaveExpenseStarted(Guid.NewGuid()); eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 1); }); Assert.AreEqual(1, eventsDataTable.Rows.Count); Assert.AreEqual(ThreadHelper.GetCurrentUnManagedThreadId(), Convert.ToInt32(eventsDataTable.Rows[0]["ThreadId"])); }
public void WhenSinkNameIsDuplicated1() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProc.Logger; EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); var subject = new EventEntrySubject(); subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(10), 200); SinkSettings sinkSettings = new SinkSettings("dbSink", subject, new List <EventSourceSettings>() { { settings } }); var subject2 = new EventEntrySubject(); subject2.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(10), 200); SinkSettings sinkSettings2 = new SinkSettings("dbSink", subject2, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { sinkSettings, sinkSettings2 }; var exc = ExceptionAssertHelper. Throws <Microsoft.Practices.EnterpriseLibrary.SemanticLogging.Etw.Configuration.ConfigurationException>( () => new TraceEventServiceConfiguration(sinks)); StringAssert.Contains(exc.ToString(), "Duplicate sinks"); }
public void TwoCollectorsSameEventSource() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(); 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.LogToSqlDatabase("testInstance", validConnectionString, "Traces", TimeSpan.FromSeconds(1), 1); SinkSettings sinkSettings2 = new SinkSettings("dbSink2", subject2, new List <EventSourceSettings>() { { settings } }); System.Data.DataTable eventsDataTable = null; List <SinkSettings> sinks = new List <SinkSettings>() { sinkSettings, sinkSettings2 }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); 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, 20); } finally { collector.Stop(); collector2.Stop(); } } Assert.AreEqual(20, eventsDataTable.Rows.Count); StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message"); }
public TraceEventServiceWorker(SinkSettings sinkSettings, TraceEventServiceSettings serviceSettings) { Guard.ArgumentNotNull(sinkSettings, "sinkSettings"); Guard.ArgumentNotNull(serviceSettings, "serviceSettings"); this.sink = sinkSettings.Sink; this.eventSources = new List <Configuration.EventSourceSettings>(sinkSettings.EventSources); this.sessionName = serviceSettings.SessionNamePrefix + "-" + sinkSettings.Name; this.Initialize(); }
protected override void When() { var current = this.configuration.SinkSettings[0]; current.EventSources.First().Level = EventLevel.Warning; var newSink = new SinkSettings(current.Name, current.Sink, current.EventSources); // will trigger changed event this.configuration.SinkSettings.Remove(current); this.configuration.SinkSettings.Add(newSink); }
public void when_creating_instance_with_default_values() { var sources = new List <EventSourceSettings>() { new EventSourceSettings(MyCompanyEventSource.Log.Name) }; var sink = new InMemoryEventListener(); var sut = new SinkSettings("test", sink, sources); Assert.AreEqual("test", sut.Name); Assert.AreEqual(sink, sut.Sink); Assert.AreEqual(1, sut.EventSources.Count()); }
public void when_creating_instance_with_duplicate_sinkSettings() { var sinks = new List <SinkSettings>(); var sources = new List <EventSourceSettings> { new EventSourceSettings("test"), new EventSourceSettings("test") }; var sink = new SinkSettings("test", new Lazy <IObserver <EventEntry> >(() => new InMemoryEventListener()), sources); sinks.Add(sink); sinks.Add(sink); new TraceEventServiceConfiguration(sinks); }
public void WhenTwoEventSourcesAreUsedInOneCollector() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProc.Logger; var logger2 = MockEventSourceOutProc2.Logger; EventTextFormatter formatter = new EventTextFormatter(); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); EventSourceSettings settings2 = new EventSourceSettings("MockEventSourceOutProc2", 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, settings2 }); List <SinkSettings> sinks = new List <SinkSettings>() { sinkSettings }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); TestScenario.WithConfiguration( svcConfiguration, () => { for (int n = 0; n < 200; n++) { logger.LogSomeMessage("some message" + n.ToString()); } var eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 200); Assert.AreEqual(200, eventsDataTable.Rows.Count); StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), "some message"); DatabaseHelper.CleanLoggingDB(validConnectionString); for (int n = 0; n < 200; n++) { logger2.LogSomeMessage("some message" + n.ToString()); } var eventsDataTable2 = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 200); Assert.AreEqual(200, eventsDataTable2.Rows.Count); StringAssert.Contains(eventsDataTable2.Rows[0]["payload"].ToString(), "some message"); }); }
protected override void When() { var current = this.configuration.SinkSettings[0]; var newSources = new List <SemanticLogging.Etw.Configuration.EventSourceSettings>(current.EventSources); newSources.Add(new SemanticLogging.Etw.Configuration.EventSourceSettings(EventSource.GetName(typeof(TestEventSource)))); var newSink = new SinkSettings(current.Name, current.Sink, newSources); // will trigger changed event this.configuration.SinkSettings.Remove(current); this.configuration.SinkSettings.Add(newSink); // We expect 2 events this.inMemoryListener.WaitSignalCondition = () => inMemoryListener.EventWrittenCount == 2; }
public void WhenUsingCustomFormatterProgramatically() { string fileName = "FlatFileCustomFormatterProgrammatic.log"; File.Delete(fileName); var logger = MockEventSourceOutProc.Logger; CustomFormatterWithWait formatter = new CustomFormatterWithWait(); formatter.Detailed = System.Diagnostics.Tracing.EventLevel.LogAlways; formatter.Header = "---------------"; formatter.DateTimeFormat = "d"; IEnumerable <string> entries = null; EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, System.Diagnostics.Tracing.EventLevel.Critical); var subject = new EventEntrySubject(); subject.LogToFlatFile(fileName, formatter); SinkSettings sinkSettings = new SinkSettings("flatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); using (TraceEventService collector = new TraceEventService(svcConfiguration)) { try { collector.Start(); logger.Critical("some message using formatter"); entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 1, "---------------"); } finally { collector.Stop(); } } StringAssert.Contains(entries.First(), "Mock SourceId"); StringAssert.Contains(entries.First(), "Mock EventId"); StringAssert.Contains(entries.First(), "Payload : [message : some message using formatter]"); }
public void FlatFileSomeFilteredSomeNot() { var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(EventTextFormatter.DashSeparator); var fileName = "FlatFileAllFiltered.log"; File.Delete(fileName); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.Error); var subject = new EventEntrySubject(); subject.LogToFlatFile(fileName, formatter); SinkSettings sinkSettings = new SinkSettings("flatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); IEnumerable <string> entries = null; using (TraceEventService collector = new TraceEventService(svcConfiguration)) { collector.Start(); try { for (int n = 0; n < 200; n++) { logger.LogSomeMessage("some message " + n.ToString()); logger.Critical("some error " + n.ToString()); } entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 200, EventTextFormatter.DashSeparator); } finally { collector.Stop(); } } Assert.AreEqual(200, entries.Count()); StringAssert.Contains(entries.First(), "some error 0"); StringAssert.Contains(entries.Last(), "some error 199"); }
public void WhenUsingRollingSinkProgramatic() { var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(EventTextFormatter.DashSeparator); var fileName = "newRollingFlatfileSerial.log"; File.Delete(fileName); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); var subject = new EventEntrySubject(); subject.LogToRollingFlatFile(fileName, 100, "d", RollFileExistsBehavior.Overwrite, RollInterval.Day, formatter); SinkSettings sinkSettings = new SinkSettings("rollingFlatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); IEnumerable <string> entries = null; using (TraceEventService collector = new TraceEventService(svcConfiguration)) { collector.Start(); try { for (int n = 0; n < 200; n++) { logger.LogSomeMessage("some message" + n.ToString()); } entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 200, EventTextFormatter.DashSeparator); } finally { collector.Stop(); } } Assert.AreEqual(200, entries.Count()); StringAssert.Contains(entries.First(), "some message0"); StringAssert.Contains(entries.Last(), "some message199"); }
public void WhenConfiguringProgrammatically() { this.tableName = "testoutofprocazuretables"; var connectionString = System.Configuration.ConfigurationManager.AppSettings["StorageConnectionString"]; AzureTableHelper.DeleteTable(connectionString, this.tableName); var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(); IEnumerable <WindowsAzureTableEventEntry> events = null; EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); var subject = new EventEntrySubject(); subject.LogToWindowsAzureTable("AzureInstance", connectionString, tableName, TimeSpan.FromSeconds(1)); SinkSettings sinkSettings = new SinkSettings("azureSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); using (TraceEventService collector = new TraceEventService(svcConfiguration)) { try { collector.Start(); for (int i = 0; i < 10; i++) { logger.Critical("Critical message"); } events = AzureTableHelper.PollForEvents(connectionString, this.tableName, 10); } finally { collector.Stop(); } } Assert.AreEqual <int>(10, events.Count()); Assert.AreEqual <int>(2, events.First().EventId); }
public void WhenCustomFormatterThrowsAnExceptionAndUsedProgramatically() { string fileName = "FlatFileOutProcCustomFormatterHandleException.log"; File.Delete(fileName); var logger = MockEventSourceOutProc.Logger; MockFormatter formatter = new MockFormatter(true); //this formatter throws EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.Informational); var subject = new EventEntrySubject(); subject.LogToFlatFile(fileName, formatter); SinkSettings sinkSettings = new SinkSettings("flatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); TestScenario.WithConfiguration( svcConfiguration, () => { using (var collectErrorsListener = new InMemoryEventListener()) { try { collectErrorsListener.EnableEvents(SemanticLoggingEventSource.Log, EventLevel.LogAlways, Keywords.All); logger.LogSomeMessage("some message using formatter that throws"); collectErrorsListener.WaitEvents.Wait(5000); StringAssert.Contains(collectErrorsListener.ToString(), "Payload : [message : System.InvalidOperationException: Operation is not valid due to the current state of the object."); } finally { collectErrorsListener.DisableEvents(SemanticLoggingEventSource.Log); } } }); }
public void WhenEnumsInPayload() { var validConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["valid"].ConnectionString; DatabaseHelper.CleanLoggingDB(validConnectionString); var logger = MockEventSourceOutProcEnum.Logger; EventTextFormatter formatter = new EventTextFormatter(); System.Data.DataTable eventsDataTable = null; var subject = new EventEntrySubject(); subject.LogToSqlDatabase("testInstance", validConnectionString, "Traces", bufferingCount: 1); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProcEnum", null, EventLevel.LogAlways); SinkSettings sinkSettings = new SinkSettings("sqlDBsink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); using (TraceEventService collector = new TraceEventService(svcConfiguration)) { collector.Start(); try { logger.SendEnumsEvent16(MockEventSourceOutProcEnum.MyColor.Blue, MockEventSourceOutProcEnum.MyFlags.Flag3); eventsDataTable = DatabaseHelper.PollUntilEventsAreWritten(validConnectionString, 1); } finally { collector.Stop(); } } Assert.AreEqual(1, eventsDataTable.Rows.Count); StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), @"""a"": 1"); StringAssert.Contains(eventsDataTable.Rows[0]["payload"].ToString(), @"""b"": 4"); }
public void WhenUsingFlatFileSinkProgrammatic() { var logger = MockEventSourceOutProc.Logger; EventTextFormatter formatter = new EventTextFormatter(EventTextFormatter.DashSeparator); var fileName = "newflatfileSerial.log"; File.Delete(fileName); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); var subject = new EventEntrySubject(); subject.LogToFlatFile(fileName, formatter); SinkSettings sinkSettings = new SinkSettings("flatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); IEnumerable <string> entries = null; TestScenario.WithConfiguration( svcConfiguration, () => { for (int n = 0; n < 200; n++) { logger.LogSomeMessage("some message" + n.ToString()); } entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 200, EventTextFormatter.DashSeparator); }); Assert.AreEqual(200, entries.Count()); StringAssert.Contains(entries.First(), "some message0"); StringAssert.Contains(entries.Last(), "some message199"); }
public void WhenUsingCustomSinkProgrammatically() { string fileName = "ProvidedCustomSink.log"; File.Delete(fileName); var logger = MockEventSourceOutProc.Logger; var formatter = new EventTextFormatter(); IEnumerable <string> entries = null; var subject = new EventEntrySubject(); subject.LogToMockFlatFile(fileName, "==-=="); EventSourceSettings settings = new EventSourceSettings("MockEventSourceOutProc", null, EventLevel.LogAlways); SinkSettings sinkSettings = new SinkSettings("MockFlatFileSink", subject, new List <EventSourceSettings>() { { settings } }); List <SinkSettings> sinks = new List <SinkSettings>() { { sinkSettings } }; TraceEventServiceConfiguration svcConfiguration = new TraceEventServiceConfiguration(sinks); TestScenario.WithConfiguration( svcConfiguration, () => { logger.LogSomeMessage("some message"); logger.LogSomeMessage("some message2"); logger.LogSomeMessage("some message3"); entries = FlatFileHelper.PollUntilTextEventsAreWritten(fileName, 3, "==-=="); }); Assert.AreEqual <int>(3, entries.Count()); Assert.IsNotNull(entries.SingleOrDefault(e => e.Contains("Payload : [message : some message]"))); Assert.IsNotNull(entries.SingleOrDefault(e => e.Contains("Payload : [message : some message2]"))); Assert.IsNotNull(entries.SingleOrDefault(e => e.Contains("Payload : [message : some message3]"))); }
public void TwoCollectorsSameEventSourceDifferentSinkTypes() { 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 SubSourceLogic(SourceShape <Tuple <TopicPartition, Source <TMessage, NotUsed> > > shape, SinkSettings <TKey, TValue> settings, ITopicSubscription subscription) : base(shape) { }
public static Flow <KafkaMessage <TKey, TValue, TPass>, KafkaResult <TKey, TValue, TPass>, NotUsed> Flow <TKey, TValue, TPass>( SinkSettings <TKey, TValue> settings) { throw new NotImplementedException(); }
protected override void Given() { this.sinkSettings = new SinkSettings("test", new InMemoryEventListener(), new[] { new SemanticLogging.Etw.Configuration.EventSourceSettings("Test") }); this.traceEventServiceSettings = new TraceEventServiceSettings(); }
public static Source <KafkaMessage <TKey, TValue, ICommittable>, Task> Committable <TKey, TValue>( SinkSettings <TKey, TValue> settings, CancellationToken cancellationToken) { throw new NotImplementedException(); }
protected void Start() { ModConfig modConfig = new ModConfig("SinkSettings", typeof(SinkSettings)); Settings = (SinkSettings)modConfig.Settings; if (moduleType == Type.Faulty && Settings.fault == "0") { moduleType = Type.Normal; BombModule.ModuleDisplayName = "Sink"; BombModule.ModuleType = "Sink"; } Sink_moduleId = Sink_moduleIdCounter++; ColKnobs = UnityEngine.Random.Range(0, 3); ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); Rules = new bool[6] { BombInfo.GetOffIndicators().Contains("NSA"), BombInfo.GetSerialNumberLetters().Any("AEIOU".Contains), (ColKnobs == 2), (ColFaucet == 1), (ColPipe == 0), (BombInfo.GetPorts().Contains("HDMI") || BombInfo.GetPorts().Contains("RJ45")) }; if (moduleType == Type.Normal && BombModule.GetComponent <KMSelectable>().Children.Count() > 2) { for (int i = 1; i < 8; i++) { if (i != 2) { BombModule.GetComponent <KMSelectable>().Children[i] = null; } } } if (moduleType == Type.Faulty) { spin = UnityEngine.Random.Range(0, 20); if (spin > 15) { rotate = true; } var faulty = UnityEngine.Random.Range(0, 5); Faucet = BombModule.GetComponent <KMSelectable>().Children[1]; Basin = BombModule.GetComponent <KMSelectable>().Children[3]; Pipe = BombModule.GetComponent <KMSelectable>().Children[7]; BombModule.GetComponent <KMSelectable>().Children[1] = null; for (int i = 3; i < 8; i++) { BombModule.GetComponent <KMSelectable>().Children[i] = null; } switch (faulty) { case 0: PipeMesh.material.color = Color.black; ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; for (int i = 3; i < 6; i++) { BombModule.GetComponent <KMSelectable>().Children[i] = Basin; } Basin.OnInteract += delegate() { FaultyPVC(1); return(false); }; Hot.OnInteract += delegate() { FaultyPVC(0); return(false); }; Cold.OnInteract += delegate() { FaultyPVC(2); return(false); }; BombModule.GetComponent <KMSelectable>().UpdateChildren(); goto start; case 1: ColPipe = 2; PipeMesh.material.color = new Color(0, 157 / 255f, 1); Rules[4] = false; Rules = Rules.Select(x => !x).ToArray(); break; case 2: var r = UnityEngine.Random.Range(0, 2); ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; if (r == 0) { ColdMesh.material = null; } else { HotMesh.material = null; } BombModule.GetComponent <KMSelectable>().Children[1] = Faucet; BombModule.GetComponent <KMSelectable>().Children[7] = Pipe; BombModule.GetComponent <KMSelectable>().UpdateChildren(); while (ColFaucet == ColPipe && ColKnobs == ColPipe) { ColFaucet = UnityEngine.Random.Range(0, 3); ColPipe = UnityEngine.Random.Range(0, 3); } if (!ColFaucet.Equals(ColKnobs) && !ColPipe.Equals(ColKnobs)) { ColPipe = ColKnobs; } FaucetMesh.material.mainTexture = knobColors[ColFaucet]; PipeMesh.material.mainTexture = knobColors[ColPipe]; if (!ColPipe.Equals(ColKnobs)) { PipeMesh.material.mainTexture = null; } Faucet.OnInteract = ButtonHandler(Faucet, 1, r); Pipe.OnInteract = ButtonHandler(Pipe, 1, r); Cold.OnInteract = ButtonHandler(Cold, 1, r); Hot.OnInteract = ButtonHandler(Hot, 1, r); Rules[3] = ColFaucet.Equals(1); Rules[4] = ColPipe.Equals(0); goto start; case 3: rotate = false; var s = UnityEngine.Random.Range(0, 2); var selectable = new[] { Faucet, Pipe }; Hot.OnInteract += delegate() { BombModule.HandleStrike(); DebugLog("Warning: Overheating"); return(false); }; if (s == 0) { Hot = Faucet; BombModule.GetComponent <KMSelectable>().Children[1] = Faucet; } else { Hot = Pipe; BombModule.GetComponent <KMSelectable>().Children[7] = Pipe; } ColKnobs = 0; ColFaucet = 0; ColPipe = 2; Rules[2] = false; Rules[3] = false; Rules[4] = false; ColdMesh.material.color = Color.black; HotMesh.material.color = Color.black; FaucetMesh.material.color = Color.black; PipeMesh.material.color = Color.black; Steps(); goto start; case 4: BombModule.transform.Rotate(0, 180, 0); Rules = Rules.Reverse().ToArray(); switch (BombInfo.GetBatteryCount()) { case 0: case 1: selectedRules = new[] { 4, 6, 5 }; break; case 2: case 3: selectedRules = new[] { 1, 3, 5 }; Rules = Rules.Select(x => !x).ToArray(); break; case 4: case 5: selectedRules = new[] { 2, 6, 3 }; Rules = Rules.Select(x => !x).ToArray(); break; default: selectedRules = new[] { 4, 1, 2 }; break; } ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; knob1 = Rules[selectedRules[0] - 1]; knob2 = Rules[selectedRules[1] - 1]; knob3 = Rules[selectedRules[2] - 1]; if (ColPipe != 2) { PipeMesh.material.mainTexture = knobColors[ColPipe]; } DebugLog("Third Knob: {0}", knob1 ? "Hot" : "Cold"); DebugLog("Second Knob: {0}", knob2 ? "Hot" : "Cold"); DebugLog("First Knob: {0}", knob3 ? "Hot" : "Cold"); DebugLog("Knobs are {0}, Faucet is {1}, Drain Pipe is {2}", textureList[ColKnobs], textureList[ColFaucet], colorList[ColPipe]); StartCoroutine(CheckForTurn()); Cold.OnInteract = ButtonHandler(Cold, 0); Hot.OnInteract = ButtonHandler(Hot, 0); canPress = true; BombModule.GetComponent <KMSelectable>().UpdateChildren(); goto start; } } ColdMesh.material.mainTexture = knobColors[ColKnobs]; HotMesh.material.mainTexture = knobColors[ColKnobs]; FaucetMesh.material.mainTexture = knobColors[ColFaucet]; if (ColPipe != 2) { PipeMesh.material.mainTexture = knobColors[ColPipe]; } Steps(); start : return; }
protected override void Given() { this.sinkSettings = new SinkSettings("test", new InMemoryEventListener(), new[] { new EventSourceSettings("Test") }); this.traceEventServiceSettings = new TraceEventServiceSettings(); }
public static Source <RdKafka.Message, Task> Standard <TKey, TValue>( SinkSettings <TKey, TValue> settings, CancellationToken cancellationToken) { throw new NotImplementedException(); }