public void SutIsRequestSpecification() { // Fixture setup // Exercise system var sut = new ParameterSpecification(typeof(object), "someName"); // Verify outcome Assert.IsAssignableFrom<IRequestSpecification>(sut); // Teardown }
public void IsSatisfiedByWithNullRequestShouldThrowArgumentNullException() { // Fixture setup var sut = new ParameterSpecification(typeof(object), "someName"); // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.IsSatisfiedBy(null)); // Teardown }
public void InitializeWithParameterNameShouldSetCorrespondingProperty() { // Fixture setup var type = typeof(object); var name = "someName"; // Exercise system var sut = new ParameterSpecification(type, name); // Verify outcome #pragma warning disable 618 Assert.Equal(type, sut.TargetType); Assert.Equal(name, sut.TargetName); #pragma warning restore 618 // Teardown }
public void IsSatisfiedByWithRequestForParameterShouldReturnCorrectResult( string parameterName, string requestedName, bool expectedResult) { // Fixture setup var sut = new ParameterSpecification(typeof(object), parameterName); var request = typeof(SingleParameterType<object>) .GetConstructor(new[] { typeof(object) }) .GetParameters() .Single(p => p.Name == requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void IsSatisfiedByReturnsCorrectResultAccordingToTarget( bool expected) { var parameter = typeof(string).GetMethod("Contains").GetParameters().First(); var target = new DelegatingCriterion<ParameterInfo> { OnEquals = f => { Assert.Equal(parameter, f); return expected; } }; var sut = new ParameterSpecification(target); var actual = sut.IsSatisfiedBy(parameter); Assert.Equal(expected, actual); }
public void IsSatisfiedByWithInvalidRequestShouldReturnFalse(object request) { // Fixture setup var sut = new ParameterSpecification(typeof(object), "someName"); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }
public void IsSatisfiedByWithRequestForMemberOtherThanParameterWithSameNameShouldReturnFalse() { // Fixture setup var parameterName = "Parameter"; var requestedName = "Parameter"; var sut = new ParameterSpecification(typeof(object), parameterName); var request = typeof(SingleParameterType<object>).GetProperty(requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }
public void IsSatisfiedByWithRequestForParameterWithSameNameAndIncompatibleTypeShouldReturnFalse() { // Fixture setup var parameterName = "parameter"; var requestedName = "parameter"; var sut = new ParameterSpecification(typeof(object), parameterName); var request = typeof(SingleParameterType<int>) .GetConstructor(new[] { typeof(int) }) .GetParameters() .Single(p => p.Name == requestedName); // Exercise system var result = sut.IsSatisfiedBy(request); // Verify outcome Assert.False(result); // Teardown }