Ejemplo n.º 1
0
        public void CreateWithNonParameterInfoRequestReturnsNoSpecimen(object request)
        {
            var fixture     = new Fixture();
            var contextMock = new Mock <ISpecimenContext>();
            var sut         = new SutAlias(
                typeof(ParameterSpecimenBuilderTests),
                fixture.Create <string>());

            var actual = sut.Create(request, contextMock.Object);

            Assert.IsType <NoSpecimen>(actual);
            Assert.NotSame(sut.SpecimenValue, actual);
        }
Ejemplo n.º 2
0
        public void CreateWithRequestThatMatchesParametersReturnsSpecimenValue()
        {
            var fixture       = new Fixture();
            var specimenValue = fixture.Create <string>();
            var parameterInfo = typeof(ParameterSpecimenBuilderTests)
                                .GetMethod(nameof(TestMethodStub), BindingFlags.Static | BindingFlags.NonPublic)
                                .GetParameters()
                                .First();
            var contextMock = new Mock <ISpecimenContext>();
            var sut         = new SutAlias(
                typeof(ParameterSpecimenBuilderTests),
                parameterInfo.Name,
                specimenValue);

            var actual = sut.Create(parameterInfo, contextMock.Object);

            Assert.Equal(specimenValue, actual);
        }
Ejemplo n.º 3
0
        public void CreateWithRequestThatDoesNotMatchParametersReturnsNoSpecimen(
            Type declaringType,
            string parameterName,
            object specimenValue)
        {
            var parameterInfo = typeof(ParameterSpecimenBuilderTests)
                                .GetMethod(nameof(TestMethodStub), BindingFlags.Static | BindingFlags.NonPublic)
                                .GetParameters()
                                .First();
            var contextMock = new Mock <ISpecimenContext>();
            var sut         = new SutAlias(
                declaringType,
                parameterName,
                specimenValue);

            var actual = sut.Create(parameterInfo, contextMock.Object);

            Assert.IsType <NoSpecimen>(actual);
            Assert.NotSame(sut.SpecimenValue, actual);
        }