示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        public void ReadModePropertyInfo_WithNull_ThrowsArgumentNullException()
        {
            IFormattingModeReader reader = new CachedFormattingModeReader(Substitute.For <IFormattingModeReader>());

            reader.ReadMode((PropertyInfo)null);
        }
示例#5
0
 public void Constructor_WithNull_ThrowsArgumentNullException()
 {
     // ReSharper disable once UnusedVariable
     IFormattingModeReader reader = new CachedFormattingModeReader(null);
 }