Example #1
0
        public void DisposeClearsTrackers()
        {
            // Arrange
            var sut = new DisposableTrackingBehavior();

            sut.Transform(new DelegatingSpecimenBuilder());
            sut.Transform(new DelegatingSpecimenBuilder());
            sut.Transform(new DelegatingSpecimenBuilder());
            // Act
            sut.Dispose();
            // Assert
            Assert.Empty(sut.Trackers);
        }
Example #2
0
        public void DisposeClearsTrackers()
        {
            // Fixture setup
            var sut = new DisposableTrackingBehavior();

            sut.Transform(new DelegatingSpecimenBuilder());
            sut.Transform(new DelegatingSpecimenBuilder());
            sut.Transform(new DelegatingSpecimenBuilder());
            // Exercise system
            sut.Dispose();
            // Verify outcome
            Assert.Empty(sut.Trackers);
            // Teardown
        }
Example #3
0
        public void TransformAddsItemsToTrackers()
        {
            // Arrange
            var sut = new DisposableTrackingBehavior();
            // Act
            var trackers = new[]
            {
                sut.Transform(new DelegatingSpecimenBuilder()),
                sut.Transform(new DelegatingSpecimenBuilder()),
                sut.Transform(new DelegatingSpecimenBuilder())
            };

            // Assert
            Assert.True(trackers.All(sb => sut.Trackers.Any(dt => sb == dt)));
        }
Example #4
0
        public void TransformAddsItemsToTrackers()
        {
            // Fixture setup
            var sut = new DisposableTrackingBehavior();
            // Exercise system
            var trackers = new[]
            {
                sut.Transform(new DelegatingSpecimenBuilder()),
                sut.Transform(new DelegatingSpecimenBuilder()),
                sut.Transform(new DelegatingSpecimenBuilder())
            };

            // Verify outcome
            Assert.True(trackers.All(sb => sut.Trackers.Any(dt => sb == dt)));
            // Teardown
        }
Example #5
0
        public void TransformReturnsCorrectSpecimenBuilderType()
        {
            // Arrange
            var sut = new DisposableTrackingBehavior();
            // Act
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var result       = sut.Transform(dummyBuilder);

            // Assert
            Assert.IsAssignableFrom <DisposableTracker>(result);
        }
Example #6
0
        public void TransformReturnsCorrectSpecimenBuilderType()
        {
            // Fixture setup
            var sut = new DisposableTrackingBehavior();
            // Exercise system
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var result       = sut.Transform(dummyBuilder);

            // Verify outcome
            Assert.IsAssignableFrom <DisposableTracker>(result);
            // Teardown
        }
Example #7
0
        public void TransformReturnsCorrectResult()
        {
            // Arrange
            var sut             = new DisposableTrackingBehavior();
            var expectedBuilder = new DelegatingSpecimenBuilder();
            // Act
            var result = sut.Transform(expectedBuilder);
            // Assert
            var tracker = Assert.IsAssignableFrom <DisposableTracker>(result);

            Assert.Equal(expectedBuilder, tracker.Builder);
        }
Example #8
0
        public void TransformReturnsCorrectResult()
        {
            // Fixture setup
            var sut             = new DisposableTrackingBehavior();
            var expectedBuilder = new DelegatingSpecimenBuilder();
            // Exercise system
            var result = sut.Transform(expectedBuilder);
            // Verify outcome
            var tracker = Assert.IsAssignableFrom <DisposableTracker>(result);

            Assert.Equal(expectedBuilder, tracker.Builder);
            // Teardown
        }
Example #9
0
        public void DisposeDisposesTrackers()
        {
            // Arrange
            var sut     = new DisposableTrackingBehavior();
            var builder = new DelegatingSpecimenBuilder {
                OnCreate = (r, c) => new DisposableSpy()
            };
            var trackers = new[]
            {
                (DisposableTracker)sut.Transform(builder),
                (DisposableTracker)sut.Transform(builder),
                (DisposableTracker)sut.Transform(builder)
            };

            trackers.ToList().ForEach(dt => Enumerable.Repeat(new object(), 3).Select(r => dt.Create(r, new DelegatingSpecimenContext())).ToList());
            // Act
            sut.Dispose();
            // Assert
            Assert.True((from dt in trackers
                         from d in dt.Disposables
                         select d).Cast <DisposableSpy>().All(ds => ds.Disposed));
        }