public void CreateWithPropertyDecoratedWithRangeAttributeReturnsCorrectResult( string name, object attributeMinimum, object attributeMaximum) { // Fixture setup var request = typeof(RangeValidatedType).GetProperty(name); Type target = Nullable.GetUnderlyingType(request.PropertyType) ?? request.PropertyType; var expectedRequest = new RangedNumberRequest( target, Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture), Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture) ); 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 RangeAttributeRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithFieldDecoratedWithRangeAttributeReturnsCorrectResult( Type attributeType, object attributeMinimum, object attributeMaximum) { // Fixture setup var request = typeof(RangeValidatedType).GetField("Field"); Type target = request.FieldType; var expectedRequest = new RangedNumberRequest( target, Convert.ChangeType(RangeValidatedType.Minimum, target, CultureInfo.CurrentCulture), Convert.ChangeType(RangeValidatedType.Maximum, target, CultureInfo.CurrentCulture) ); var expectedResult = new object(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r) }; var sut = new RangeAttributeRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithRangeAttributeRequestReturnsCorrectResult(Type type, object minimum, object maximum) { // Fixture setup var rangeAttribute = new RangeAttribute(type, minimum.ToString(), maximum.ToString()); var providedAttribute = new ProvidedAttribute(rangeAttribute, true); ICustomAttributeProvider request = new FakeCustomAttributeProvider(providedAttribute); Type conversionType = rangeAttribute.OperandType; var expectedRequest = new RangedNumberRequest( conversionType, Convert.ChangeType(rangeAttribute.Minimum, conversionType, CultureInfo.CurrentCulture), Convert.ChangeType(rangeAttribute.Maximum, conversionType, CultureInfo.CurrentCulture) ); var expectedResult = new object(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen(r) }; var sut = new RangeAttributeRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void SutIsSpecimenBuilder() { // Arrange // Act var sut = new RangeAttributeRelay(); // Assert Assert.IsAssignableFrom <ISpecimenBuilder>(sut); }
public void SutIsSpecimenBuilder() { // Fixture setup // Exercise system var sut = new RangeAttributeRelay(); // Verify outcome Assert.IsAssignableFrom <ISpecimenBuilder>(sut); // Teardown }
public void CreateWithNullContextThrows() { // Arrange var sut = new RangeAttributeRelay(); var dummyRequest = new object(); // Act & assert Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); }
public void CreateWithNullContextThrows() { // Fixture setup var sut = new RangeAttributeRelay(); var dummyRequest = new object(); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); // Teardown }
public void CreateWithNullRequestReturnsCorrectResult() { // Arrange var sut = new RangeAttributeRelay(); // Act var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContext); // Assert Assert.Equal(new NoSpecimen(), result); }
public void CreateWithNullRequestReturnsCorrectResult() { // Fixture setup var sut = new RangeAttributeRelay(); // Exercise system var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContext); // Verify outcome Assert.Equal(new NoSpecimen(), result); // Teardown }
public void CreateWithNonRangeAttributeRequestReturnsCorrectResult(object request) { // Arrange var sut = new RangeAttributeRelay(); // Act var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContext); // Assert var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); }
public void CreateWithNonRangeAttributeRequestReturnsCorrectResult(object request) { // Fixture setup var sut = new RangeAttributeRelay(); // 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() { // Arrange var sut = new RangeAttributeRelay(); var dummyRequest = new object(); // Act var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Assert var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); }
public void CreateWithAnonymousRequestReturnsCorrectResult() { // Fixture setup var sut = new RangeAttributeRelay(); var dummyRequest = new object(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(dummyRequest, dummyContainer); // Verify outcome #pragma warning disable 618 var expectedResult = new NoSpecimen(dummyRequest); #pragma warning restore 618 Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithPropertyDecoratedWithRangeAttributeReturnsCorrectResult( string name, Type expectedMemberType, Type expectedOperandType) { // Arrange var request = typeof(RangeValidatedType).GetProperty(name); var expectedRequest = new RangedRequest( expectedMemberType, expectedOperandType, RangeValidatedType.Minimum, RangeValidatedType.Maximum); var expectedResult = new object(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new RangeAttributeRelay(); // Act var result = sut.Create(request, context); // Assert Assert.Equal(expectedResult, result); }
public void CreateWithRangeAttributeRequestReturnsCorrectResult(Type type, object minimum, object maximum) { // Arrange var rangeAttribute = new RangeAttribute(type, minimum.ToString(), maximum.ToString()); var providedAttribute = new ProvidedAttribute(rangeAttribute, true); var request = new FakeMemberInfo(providedAttribute); Type conversionType = rangeAttribute.OperandType; var expectedRequest = new RangedRequest(conversionType, conversionType, rangeAttribute.Minimum, rangeAttribute.Maximum); var expectedResult = new object(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new RangeAttributeRelay(); // Act var result = sut.Create(request, context); // Assert Assert.Equal(expectedResult, result); }
public void CreateWithParameterDecoratedWithRangeAttributeReturnsCorrectResult( string methodName, Type expectedMemberType, Type expectedOperandType) { // Fixture setup var request = typeof(RangeValidatedType).GetMethod(methodName).GetParameters().Single(); var expectedRequest = new RangedRequest( expectedMemberType, expectedOperandType, RangeValidatedType.Minimum, RangeValidatedType.Maximum); var expectedResult = new object(); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new RangeAttributeRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }