Beispiel #1
0
        public void WritingLogEntryIndentsAllLinesOfMessage()
        {
            var creatorType = typeof(DefaultTypeCreator);

            var sut = new DefaultBuildLog {
                IsEnabled = true
            };

            Exception exception;

            try
            {
                throw new TimeoutException();
            }
            catch (TimeoutException ex)
            {
                // Get the exception with a valid stack trace
                exception = ex;
            }

            sut.CreatingType(typeof(Person), creatorType, null !);
            sut.BuildFailure(exception);
            sut.CreatedType(typeof(Person), null !);

            var lines = sut.Output.Split(
                new[]
            {
                Environment.NewLine
            },
                StringSplitOptions.RemoveEmptyEntries);
            var indentedLines = lines.Skip(1).Take(lines.Length - 2);

            indentedLines.All(x => x.StartsWith("    ", StringComparison.OrdinalIgnoreCase)).Should().BeTrue();
        }
Beispiel #2
0
        public void CreatingTypeDoesNotWriteLogWhenDisabled()
        {
            var creatorType = typeof(DefaultTypeCreator);

            var sut = new DefaultBuildLog();

            sut.CreatingType(typeof(string), creatorType, null !);

            sut.Output.Should().BeEmpty();
        }
Beispiel #3
0
        public void CreatingTypeThrowsExceptionWithNullCreatorType()
        {
            var type = typeof(string);

            var sut = new DefaultBuildLog {
                IsEnabled = true
            };

            Action action = () => sut.CreatingType(type, null !, null !);

            action.Should().Throw <ArgumentNullException>();
        }
Beispiel #4
0
        public void CreatingTypeAppendsLogEntry()
        {
            var creatorType = typeof(DefaultTypeCreator);

            var sut = new DefaultBuildLog {
                IsEnabled = true
            };

            sut.CreatingType(typeof(string), creatorType, null !);

            sut.Output.Should().NotBeNullOrWhiteSpace();
        }
Beispiel #5
0
        public void CreateTypeIndentsChildMessages()
        {
            var generatorType = typeof(StateValueGenerator);
            var creatorType   = typeof(DefaultTypeCreator);

            var sut = new DefaultBuildLog {
                IsEnabled = true
            };

            sut.CreatingType(typeof(Person), creatorType, null !);
            sut.CreatingValue(typeof(string), generatorType, null !);
            sut.CreatedType(typeof(Person), null !);

            var actual = sut.Output;

            actual.Should().Contain("    ");
        }
        public void WritingLogEntryIndentsAllLinesOfMessageTest()
        {
            var target = new DefaultBuildLog();

            Exception exception;

            try
            {
                throw new TimeoutException();
            }
            catch (Exception ex)
            {
                // Get the exception with a valid stack trace
                exception = ex;
            }

            target.CreatingType(typeof(Person), null);
            target.BuildFailure(exception);
            target.CreatedType(typeof(Person), null);

            var lines = target.Output.Split(
                new[]
                {
                    Environment.NewLine
                },
                StringSplitOptions.RemoveEmptyEntries);
            var indentedLines = lines.Skip(1).Take(lines.Length - 2);

            indentedLines.All(x => x.StartsWith("    ")).Should().BeTrue();
        }
        public void CreatingTypeThrowsExceptionWithNullTypeTest()
        {
            var target = new DefaultBuildLog();

            Action action = () => target.CreatingType(null, null);

            action.ShouldThrow<ArgumentNullException>();
        }
        public void CreatingTypeAppendsLogEntryTest()
        {
            var target = new DefaultBuildLog();

            target.CreatingType(typeof(string), null);

            target.Output.Should().NotBeNullOrWhiteSpace();
        }
        public void CreateTypeIndentsChildMessagesTest()
        {
            var target = new DefaultBuildLog();

            target.CreatingType(typeof(Person), null);
            target.CreatingValue(typeof(string), null);
            target.CreatedType(typeof(Person), null);

            var actual = target.Output;

            actual.Should().Contain("    ");
        }