public override void OneTimeSetup()
 {
     _tracingBuilderInstanceType    = typeof(TracingBuilder);
     _tracingBuilderInstanceFixture = this.Create <TracingBuilder>(true);
     _tracingBuilderInstance        = _tracingBuilderInstanceFixture ?? this.Create <TracingBuilder>(false);
     CurrentInstance = _tracingBuilderInstanceFixture;
     ConfigureIgnoringTests(); // Configure ignoring tests.
 }
        public void AUT_TracingBuilder_Constructor_Instantiation_With_Parameter_Test()
        {
            // Arrange
            var            builder           = this.CreateType <ISpecimenBuilder>();
            TracingBuilder instance          = null;
            Exception      creationException = null;

            // Act
            Action createAction = () => instance = new TracingBuilder(builder);

            creationException = ActionAnalyzer.GetActionException(createAction);

            // Assert
            instance.ShouldNotBeNull();
            _tracingBuilderInstance.ShouldNotBeNull();
            _tracingBuilderInstanceFixture.ShouldNotBeNull();
            Should.NotThrow(createAction);
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TraceWriter"/> class.
        /// </summary>
        /// <param name="writer">The output stream for the trace.</param>
        /// <param name="tracer">The <see cref="ISpecimenBuilder"/> to decorate.</param>
        public TraceWriter(TextWriter writer, TracingBuilder tracer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (tracer == null)
            {
                throw new ArgumentNullException(nameof(tracer));
            }

            this.Tracer = tracer;
            this.Tracer.SpecimenRequested += (sender, e) => this.writeRequest(writer, e.Request, e.Depth);
            this.Tracer.SpecimenCreated   += (sender, e) => this.writeSpecimen(writer, e.Specimen, e.Depth);

            this.writer = writer;
            this.TraceRequestFormatter  = (tw, r, i) => tw.WriteLine(new string(' ', i * 2) + "Requested: " + r);
            this.TraceSpecimenFormatter = (tw, r, i) => tw.WriteLine(new string(' ', i * 2) + "Created: " + r);
        }