public void ReadModePropertyInfo_CallsTheBaseReaderAtMostOnce() { // Arrange IFormattingModeReader baseReader = Substitute.For <IFormattingModeReader>(); IFormattingModeReader reader = new CachedFormattingModeReader(baseReader); // Act reader.ReadMode(TestProperty); reader.ReadMode(TestProperty); reader.ReadMode(TestProperty); // Assert baseReader.Received(1).ReadMode(TestProperty); }
public void ReadModePropertyInfo_ReturnsTheResultOfTheBaseReader() { // Arrange IFormattingModeReader baseReader = Substitute.For <IFormattingModeReader>(); baseReader.ReadMode(TestProperty).Returns(FormattingMode.ItemsMembers); IFormattingModeReader reader = new CachedFormattingModeReader(baseReader); // Act FormattingMode mode = reader.ReadMode(TestProperty); // Assert Assert.AreEqual(FormattingMode.ItemsMembers, mode); }
public static FormattingMethodLoggerFactory Initialize( ILoggerAdapterFactory loggerAdapterFactory, IFormatProvider formatProvider, ICustomValueFormatter customValueFormatter = null) { if (loggerAdapterFactory == null) { throw new ArgumentNullException("loggerAdapterFactory"); } if (formatProvider == null) { throw new ArgumentNullException("formatProvider"); } IFormattingModeReader formattingModeReader = new CachedFormattingModeReader(new FormattingModeReader()); IMethodEventFormatter methodEventFormatter = new MethodEventFormatter(new ParameterFormatter(formattingModeReader, formatProvider, customValueFormatter)); FormattingMethodLoggerFactory factory = new FormattingMethodLoggerFactory(loggerAdapterFactory, new IndentationTracker(), methodEventFormatter); Initialize(factory); return(factory); }
public void ReadModePropertyInfo_WithNull_ThrowsArgumentNullException() { IFormattingModeReader reader = new CachedFormattingModeReader(Substitute.For <IFormattingModeReader>()); reader.ReadMode((PropertyInfo)null); }
public void Constructor_WithNull_ThrowsArgumentNullException() { // ReSharper disable once UnusedVariable IFormattingModeReader reader = new CachedFormattingModeReader(null); }