public void Register_ServiceAfterFirstGetInstance_TracesWarning() { string message = null; var container = new ServiceContainer(new ContainerOptions { LogFactory = t => m => message = m.Message }); SampleTraceListener sampleTraceListener = new SampleTraceListener(m => message = m); try { Trace.Listeners.Add(sampleTraceListener); container.Register <IFoo, Foo>(); container.GetInstance <IFoo>(); container.Register <IFoo, Foo>(); Assert.True(message.StartsWith("Cannot overwrite existing serviceregistration")); } finally { Trace.Listeners.Remove(sampleTraceListener); } }
public void Register_ServiceAfterFirstGetInstance_TracesWarning() { string message = null; var container = new ServiceContainer(new ContainerOptions {LogFactory = t => m => message = m.Message}); SampleTraceListener sampleTraceListener = new SampleTraceListener(m => message = m); try { Trace.Listeners.Add(sampleTraceListener); container.Register<IFoo, Foo>(); container.GetInstance<IFoo>(); container.Register<IFoo, Foo>(); Assert.True(message.StartsWith("Cannot overwrite existing serviceregistration")); } finally { Trace.Listeners.Remove(sampleTraceListener); } }