public void NameAndNamespace() => Assert.Equal("TheClass", TypeNameConverter.GetName("Namespace.TheClass"));
static async Task <IEnumerable <LogEventEx> > Send( object message, Action <SendOptions>?optionsAction = null, Action <EndpointConfiguration>?extraConfiguration = null) { logs.Clear(); var suffix = TypeNameConverter.GetName(message.GetType()) .Replace("<", "_") .Replace(">", "_"); var configuration = ConfigBuilder.BuildDefaultConfig("SerilogTests" + suffix); configuration.PurgeOnStartup(true); extraConfiguration?.Invoke(configuration); var serilogTracing = configuration.EnableSerilogTracing(); serilogTracing.EnableSagaTracing(); serilogTracing.UseHeaderConversion((key, _) => { if (key == "ConvertHeader") { return(new("NewKey", new ScalarValue("newValue"))); } return(null); }); serilogTracing.EnableMessageTracing(); var resetEvent = new ManualResetEvent(false); configuration.RegisterComponents(_ => _.AddSingleton(resetEvent)); var recoverability = configuration.Recoverability(); recoverability.Delayed(settings => { settings.TimeIncrease(TimeSpan.FromMilliseconds(1)); settings.NumberOfRetries(1); }); recoverability.Immediate(_ => { _.NumberOfRetries(1); }); recoverability.Failed(_ => _ .OnMessageSentToErrorQueue((_, _) => { resetEvent.Set(); return(Task.CompletedTask); })); var endpoint = await Endpoint.Start(configuration); var sendOptions = new SendOptions(); optionsAction?.Invoke(sendOptions); sendOptions.SetMessageId("00000000-0000-0000-0000-000000000001"); sendOptions.RouteToThisEndpoint(); await endpoint.Send(message, sendOptions); if (!resetEvent.WaitOne(TimeSpan.FromSeconds(10))) { throw new("No Set received."); } await endpoint.Stop(); return(logs .Where(x => !x.MessageTemplate.Text.StartsWith("Operation canceled")) .Select(x => new LogEventEx ( messageTemplate: x.MessageTemplate, level: x.Level, properties: x.Properties, exception: x.Exception ))); }
public void NameOnly() { Assert.Equal("TheClass", TypeNameConverter.GetName("TheClass")); }
public void AssemblyQualifiedWithNoVersion() { Assert.Equal("TheClass", TypeNameConverter.GetName("Namespace.TheClass, Tests")); }
public void AssemblyQualified() { Assert.Equal("TheClass", TypeNameConverter.GetName("Namespace.TheClass, Tests, Version=0.0.0.0, Culture=neutral, PublicKeyToken=ce8ec7717ba6fbb6")); }
public void NameAndNamespaceAndAssembly() { Assert.Equal("TheClass", TypeNameConverter.GetName("Namespace.TheClass, Tests")); }