public void ReturnsTheFormatterAsExpected() { var target = new ConventionBasedEventFormatterFactory(); var formatter = target.Create <GoodTraceEventWithGoodFormatter>(); Assert.IsInstanceOf <GoodFormatter>(formatter); }
public void ThrowsAnExceptionWhenTheAttributeDoesNotExist() { var target = new ConventionBasedEventFormatterFactory(); var ex = Assert.Throws <FormatterNotFoundException>(() => target.Create <TraceEvent>()); Assert.AreEqual("The formatter could not be identified.", ex.Message); Assert.AreEqual(typeof(TraceEvent), ex.TargetType); }
public void ThrowsAnExceptionWhenTheFormatterCannotBeCreated() { var target = new ConventionBasedEventFormatterFactory(); var ex = Assert.Throws <FormatterNotFoundException>(() => target.Create <BadTraceEventWithBadFormatter>()); Assert.AreEqual("The formatter could not be created. Please verify the formatter contains a parameterless constructor.", ex.Message); Assert.AreEqual(typeof(BadTraceEventWithBadFormatter), ex.TargetType); Assert.AreEqual(typeof(BadFormatter), ex.FormatterType); }
public void ThrowsAnExceptionWhenTheFormatterCannotBeCreated() { var target = new ConventionBasedEventFormatterFactory(); Assert.Throws <FormatterNotFoundException>(() => target.Create <BadTraceEventWithBadFormatter>()); }
public void ThrowsAnExceptionWhenTheFormatterIsTheWrongType() { var target = new ConventionBasedEventFormatterFactory(); Assert.Throws <InvalidOperationException>(() => target.Create <BadTraceEvent>()); }
public void ThrowsAnExceptionWhenTheAttributeDoesNotExist() { var target = new ConventionBasedEventFormatterFactory(); Assert.Throws <FormatterNotFoundException>(() => target.Create <TraceEvent>()); }