Пример #1
0
        public void CreateSeededAndCountedManyOnSpecimenBuilderReturnsCorrectResult()
        {
            // Fixture setup
            var seed     = TimeSpan.FromDays(4);
            var count    = 5;
            var expected =
                Enumerable.Range(1, count).Select(i => TimeSpan.FromHours(i));
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) =>
            {
                Assert.NotNull(c);
                Assert.Equal(
                    new FiniteSequenceRequest(
                        new SeededRequest(typeof(TimeSpan), seed), count),
                    r);
                return(expected.Cast <object>());
            };
            // Exercise system
            IEnumerable <TimeSpan> actual = builder.CreateMany(seed, count);

            // Verify outcome
            Assert.True(
                expected.SequenceEqual(actual),
                "Sequences not equal.");
            // Teardown
        }
Пример #2
0
        public void CreateCountedManyOnSpecimenBuilderReturnsCorrectResult()
        {
            // Fixture setup
            var count    = 31;
            var expected =
                Enumerable.Range(1, count).Select(i => i.ToString());
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) =>
            {
                Assert.NotNull(c);
                Assert.Equal(
                    new FiniteSequenceRequest(
                        new SeededRequest(typeof(string), null), count),
                    r);
                return(expected.Cast <object>());
            };
            // Exercise system
            IEnumerable <string> actual = builder.CreateMany <string>(count);

            // Verify outcome
            Assert.True(
                expected.SequenceEqual(actual),
                "Sequences not equal.");
            // Teardown
        }