示例#1
0
        public void SpecimenFormatterIsGivenCorrectTextWriter()
        {
            // Arrange
            var expectedWriter = new StringWriter();
            var sut            = new TraceWriter(expectedWriter, new DelegatingTracingBuilder());

            bool verified = false;

            sut.TraceSpecimenFormatter = (tw, r, i) => verified = tw == expectedWriter;
            // Act
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContainer);
            // Assert
            Assert.True(verified);
        }
示例#2
0
        public void CreateWillReturnCorrectResult()
        {
            // Arrange
            var expectedSpecimen = new object();
            var stubBuilder      = new TracingBuilder(new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => expectedSpecimen
            });

            var dummyWriter = TextWriter.Null;
            var sut         = new TraceWriter(dummyWriter, stubBuilder);
            // Act
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(dummyRequest, dummyContainer);

            // Assert
            Assert.Equal(expectedSpecimen, result);
        }
示例#3
0
        public void SpecimenFormatterIsGivenCorrectTextWriter()
        {
            // Fixture setup
            var expectedWriter = new StringWriter();
            var sut            = new TraceWriter(expectedWriter, new DelegatingTracingBuilder());

            bool verified = false;

            sut.TraceSpecimenFormatter = (tw, r, i) => verified = tw == expectedWriter;
            // Exercise system
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();

            sut.Create(dummyRequest, dummyContainer);
            // Verify outcome
            Assert.True(verified);
            // Teardown
        }
示例#4
0
        public void CreateWillInvokeDecoratedBuilderWithCorrectParameters()
        {
            // Arrange
            var expectedRequest   = new object();
            var expectedContainer = new DelegatingSpecimenContext();

            var verified    = false;
            var mockBuilder = new TracingBuilder(new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => verified = expectedRequest == r && expectedContainer == c
            });

            var dummyWriter = TextWriter.Null;
            var sut         = new TraceWriter(dummyWriter, mockBuilder);

            // Act
            sut.Create(expectedRequest, expectedContainer);
            // Assert
            Assert.True(verified, "Mock verified");
        }
示例#5
0
        public void CreateWillReturnCorrectResult()
        {
            // Fixture setup
            var expectedSpecimen = new object();
            var stubBuilder      = new TracingBuilder(new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => expectedSpecimen
            });

            var dummyWriter = TextWriter.Null;
            var sut         = new TraceWriter(dummyWriter, stubBuilder);
            // Exercise system
            var dummyRequest   = new object();
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(dummyRequest, dummyContainer);

            // Verify outcome
            Assert.Equal(expectedSpecimen, result);
            // Teardown
        }
示例#6
0
        public void CreateWillInvokeDecoratedBuilderWithCorrectParameters()
        {
            // Fixture setup
            var expectedRequest   = new object();
            var expectedContainer = new DelegatingSpecimenContext();

            var verified    = false;
            var mockBuilder = new TracingBuilder(new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => verified = expectedRequest == r && expectedContainer == c
            });

            var dummyWriter = TextWriter.Null;
            var sut         = new TraceWriter(dummyWriter, mockBuilder);

            // Exercise system
            sut.Create(expectedRequest, expectedContainer);
            // Verify outcome
            Assert.True(verified, "Mock verified");
            // Teardown
        }
示例#7
0
 public Service()
 {
     _tracewriter = TraceWriter.Create(new TraceWriterSettings());
     InitializeComponent();
 }