Пример #1
0
        public void CreateWithNullContextDoesNotThrow()
        {
            // Arrange
            var dummyRequest = new object();
            var sut          = new RandomCharSequenceGenerator();

            // Act & assert
            Assert.Null(Record.Exception(() => sut.Create(dummyRequest, null)));
        }
Пример #2
0
        public void SutIsSpecimenBuilder()
        {
            // Arrange
            // Act
            var sut = new RandomCharSequenceGenerator();

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
        }
        public void CreateWithNullContextDoesNotThrow()
        {
            // Fixture setup
            var dummyRequest = new object();
            var sut          = new RandomCharSequenceGenerator();

            // Exercise system and verify outcome
            Assert.DoesNotThrow(() => sut.Create(dummyRequest, null));
            // Teardown
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            // Exercise system
            var sut = new RandomCharSequenceGenerator();

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
Пример #5
0
        public void CreateWithCharRequestReturnsCorrectResult()
        {
            // Arrange
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Act
            var result = sut.Create(typeof(char), dummyContext);

            // Assert
            Assert.IsAssignableFrom <char>(result);
        }
        public void CreateWithCharRequestReturnsCorrectResult()
        {
            // Fixture setup
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Exercise system
            var result = sut.Create(typeof(char), dummyContext);

            // Verify outcome
            Assert.IsAssignableFrom <char>(result);
            // Teardown
        }
Пример #7
0
        public void CreateWithNonCharTypeRequestReturnsNoSpecimen(Type request)
        {
            // Arrange
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Act
            var result = sut.Create(request, dummyContext);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void CreateWithNullRequestReturnsCorrectResult()
        {
            // Fixture setup
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Exercise system
            var result = sut.Create(null, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void CreateWithNonCharTypeRequestReturnsNoSpecimen(Type request)
        {
            // Fixture setup
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Exercise system
            var result = sut.Create(request, dummyContext);

            // Verify outcome
#pragma warning disable 618
            var expectedResult = new NoSpecimen(request);
#pragma warning restore 618
            Assert.Equal(expectedResult, result);
            // Teardown
        }
Пример #10
0
        public void CreateReturnsCorrectResultOnMultipleCallWhenRunOutOfChars(
            int expected, int repeatCount)
        {
            // Arrange
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Act
            var result = Enumerable
                         .Range(1, repeatCount)
                         .Select(x => sut.Create(typeof(char), dummyContext))
                         .Cast <char>()
                         .Distinct()
                         .Count();

            // Assert
            Assert.Equal(expected, result);
        }
        public void CreateReturnsCorrectResultOnMultipleCallWhenRunOutOfChars(
            int expected, int repeatCount)
        {
            // Fixture setup
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Exercise system
            var result = Enumerable
                         .Range(1, repeatCount)
                         .Select(x => sut.Create(typeof(char), dummyContext))
                         .Cast <char>()
                         .Distinct()
                         .Count();

            // Verify outcome
            Assert.Equal(expected, result);
            // Teardown
        }
Пример #12
0
        public void CreateReturnsCorrectResultOnMultipleCall()
        {
            // Arrange
            int  printableCharactersCount = 94;
            char c        = '!';
            var  expected = Enumerable
                            .Range(1, printableCharactersCount)
                            .Select(x => c++)
                            .Cast <char>()
                            .OrderBy(x => x);
            var dummyContext = new DelegatingSpecimenContext();
            var sut          = new RandomCharSequenceGenerator();
            // Act
            var result = Enumerable
                         .Range(1, printableCharactersCount)
                         .Select(x => sut.Create(typeof(char), dummyContext))
                         .Cast <char>()
                         .OrderBy(x => x);

            // Assert
            Assert.True(expected.SequenceEqual(result));
        }