Esempio n. 1
0
        public void IsSatisfiedByNullThrows()
        {
            // Arrange
            var dummyType = typeof(object);
            var sut       = new ExactTypeSpecification(dummyType);

            // Act & assert
            Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null));
        }
        public void IsSatisfiedByNullThrows()
        {
            // Fixture setup
            var dummyType = typeof(object);
            var sut       = new ExactTypeSpecification(dummyType);

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() => sut.IsSatisfiedBy(null));
            // Teardown
        }
Esempio n. 3
0
        public void IsSatisfiedByMatchesExactlyOpenGenerics(Type specType, Type requestType, bool expectedResult)
        {
            // Arrange
            var sut = new ExactTypeSpecification(specType);
            // Act
            var result = sut.IsSatisfiedBy(requestType);

            // Assert
            Assert.Equal(expectedResult, result);
        }
Esempio n. 4
0
        public void IsSatisfiedByReturnsCorrectResult(Type specType, Type requestType, bool expectedResult)
        {
            // Arrange
            var sut = new ExactTypeSpecification(specType);
            // Act
            var result = sut.IsSatisfiedBy(requestType);

            // Assert
            Assert.Equal(expectedResult, result);
        }
        public void IsSatisfiedByReturnsCorrectResult(Type specType, Type requestType, bool expectedResult)
        {
            // Fixture setup
            var sut = new ExactTypeSpecification(specType);
            // Exercise system
            var result = sut.IsSatisfiedBy(requestType);

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        /// <summary>
        /// Generates a CultureInfo specimen based on a <see cref="CultureInfo"/> type request.
        /// </summary>
        /// <param name="request">The request that describes what to create.</param>
        /// <param name="context">A context that can be used to create other specimens.</param>
        /// <returns>
        /// The requested specimen if possible; otherwise a <see cref="NoSpecimen"/> instance.
        /// </returns>
        /// <remarks>>
        /// The generated CultureInfo will always be the same as <see cref="CultureInfo.InvariantCulture"/>.
        /// </remarks>
        public object Create(object request, ISpecimenContext context)
        {
            if (request == null)
            {
                return(new NoSpecimen());
            }

            if (!cultureTypeSpecification.IsSatisfiedBy(request))
            {
                return(new NoSpecimen());
            }
            ;

            return(CultureInfo.InvariantCulture);
        }