Create() public method

Creates a new specimen based on a specified length of characters that are allowed.
public Create ( object request, ISpecimenContext context ) : object
request object The request that describes what to create.
context ISpecimenContext A container that can be used to create other specimens.
return object
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new StringLengthAttributeRelay();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
 public void CreateWithNullRequestReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new StringLengthAttributeRelay();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext();
     var result = sut.Create(null, dummyContext);
     // Verify outcome
     Assert.Equal(new NoSpecimen(), result);
     // Teardown
 }
 public void CreateWithNonConstrainedStringRequestReturnsCorrectResult(object request)
 {
     // Fixture setup
     var sut = new StringLengthAttributeRelay();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext();
     var result = sut.Create(request, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
 public void CreateWithAnonymousRequestReturnsCorrectResult()
 {
     // Fixture setup
     var sut = new StringLengthAttributeRelay();
     var dymmyRequest = new object();
     // Exercise system
     var dummyContainer = new DelegatingSpecimenContext();
     var result = sut.Create(dymmyRequest, dummyContainer);
     // Verify outcome
     var expectedResult = new NoSpecimen(dymmyRequest);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateWithConstrainedStringRequestReturnsCorrectResult(int maximum)
        {
            // Fixture setup
            var stringLengthAttribute = new StringLengthAttribute(maximum);
            var providedAttribute = new ProvidedAttribute(stringLengthAttribute, true);
            ICustomAttributeProvider request = new FakeCustomAttributeProvider(providedAttribute);
            var expectedRequest = new ConstrainedStringRequest(stringLengthAttribute.MaximumLength);
            var expectedResult = new object();
            var context = new DelegatingSpecimenContext
            {
#pragma warning disable 618
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r)
#pragma warning restore 618
            };
            var sut = new StringLengthAttributeRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }