public void SutDoesNotEqualAnonymousObject(object other) { var sut = new ParameterInfoElement(TypeWithParameters.Parameter); var actual = sut.Equals(other); Assert.False(actual); }
public void ToElementForParameterInfoReturnsTheCorrectElement() { ParameterInfo expected = TypeWithAllElements.ParameterInfo; ParameterInfoElement actual = expected.ToElement(); Assert.Equal(new ParameterInfoElement(expected), actual); }
public void SutIsReflectionElement() { // Fixture setup // Exercise system var sut = new ParameterInfoElement(TypeWithParameters.Parameter); // Verify outcome Assert.IsAssignableFrom<IReflectionElement>(sut); // Teardown }
public void AcceptNullVisitorThrows() { // Fixture setup var sut = new ParameterInfoElement(TypeWithParameters.Parameter); // Exercise system // Verify outcome Assert.Throws<ArgumentNullException>(() => sut.Accept((IReflectionVisitor<object>)null)); // Teardown }
public void SutEqualsOtherIdenticalInstance() { var par = TypeWithParameters.Parameter; var sut = new ParameterInfoElement(par); var other = new ParameterInfoElement(par); var actual = sut.Equals(other); Assert.True(actual); }
public void GetHashCodeReturnsCorrectResult() { var par = TypeWithParameter.Parameter; var sut = new ParameterInfoElement(par); var actual = sut.GetHashCode(); var expected = par.GetHashCode(); Assert.Equal(expected, actual); }
public void SutIsReflectionElement() { // Fixture setup // Exercise system var sut = new ParameterInfoElement(TypeWithParameters.Parameter); // Verify outcome Assert.IsAssignableFrom <IReflectionElement>(sut); // Teardown }
public void SutDoesNotEqualDifferentInstanceOfSameType() { var sut = new ParameterInfoElement(TypeWithParameters.Parameter); var otherParameter = TypeWithParameters.OtherParameter; var other = new ParameterInfoElement(otherParameter); var actual = sut.Equals(other); Assert.False(actual); }
public override IReflectionVisitor <IEnumerable> Visit( ParameterInfoElement parameterInfoElement) { var v = new SemanticComparisonValue( parameterInfoElement.ParameterInfo.Name, parameterInfoElement.ParameterInfo.ParameterType); return(new SemanticReflectionVisitor( this.values.Concat(new[] { v }).ToArray())); }
public void AcceptNullVisitorThrows() { // Fixture setup var sut = new ParameterInfoElement(TypeWithParameters.Parameter); // Exercise system // Verify outcome Assert.Throws <ArgumentNullException>(() => sut.Accept((IReflectionVisitor <object>)null)); // Teardown }
public void GetHashCodeReturnsCorrectResult() { var par = TypeWithParameters.Parameter; var sut = new ParameterInfoElement(par); var actual = sut.GetHashCode(); var expected = par.GetHashCode(); Assert.Equal(expected, actual); }
public override IReflectionVisitor <bool> Visit(ParameterInfoElement parameterInfoElement) { if (object.ReferenceEquals(parameterInfoElement, null)) { throw new ArgumentNullException(nameof(parameterInfoElement)); } var pi = parameterInfoElement.ParameterInfo; return(this.Proceed(expected, this.value || this.IsMatch(pi.ParameterType, pi.Name))); }
public void ParameterInfoIsCorrect() { // Fixture setup var expected = TypeWithParameters.Parameter; var sut = new ParameterInfoElement(expected); // Exercise system ParameterInfo actual = sut.ParameterInfo; // Verify outcome Assert.Equal(expected, actual); // Teardown }
public void VisitParameterInfoElementReturnsCorrectResult() { var sut = new ReflectionVisitor(); var parameterInfoElement = new ParameterInfoElement(new Dummy().Parameter); var actual = sut.Visit(parameterInfoElement); var expected = sut; Assert.Same(expected, actual); }
public override IReflectionVisitor <IEnumerable <NameAndType> > Visit( ParameterInfoElement parameterInfoElement) { if (parameterInfoElement == null) { throw new ArgumentNullException("parameterInfoElement"); } var v = new NameAndType( parameterInfoElement.ParameterInfo.Name, parameterInfoElement.ParameterInfo.ParameterType); return(new NameAndTypeCollectingVisitor( this.values.Concat(new[] { v }).ToArray())); }
public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance() { // Fixture setup var expected = new DelegatingReflectionVisitor<int>(); var sut = new ParameterInfoElement(TypeWithParameters.Parameter); var visitor = new DelegatingReflectionVisitor<int> { OnVisitParameterInfoElement = e => e == sut ? expected : new DelegatingReflectionVisitor<int>() }; // Exercise system var actual = sut.Accept(visitor); // Verify outcome Assert.Same(expected, actual); // Teardown }
public void AcceptCallsTheCorrectVisitorMethodAndReturnsTheCorrectInstance() { // Fixture setup var expected = new DelegatingReflectionVisitor <int>(); var sut = new ParameterInfoElement(TypeWithParameters.Parameter); var visitor = new DelegatingReflectionVisitor <int> { OnVisitParameterInfoElement = e => e == sut ? expected : new DelegatingReflectionVisitor <int>() }; // Exercise system var actual = sut.Accept(visitor); // Verify outcome Assert.Same(expected, actual); // Teardown }
public void MatchContructorArgumentAgainstReadOnlyProperty( string propertyName, string parameterName, bool expected) { var prop = new PropertyInfoElement( typeof(Version).GetProperty(propertyName)); var param = new ParameterInfoElement( typeof(Version) .GetConstructor(new[] { typeof(int), typeof(int) }) .GetParameters() .Where(p => p.Name == parameterName) .Single()); var actual = new SemanticElementComparer(new SemanticReflectionVisitor()) .Equals(prop, param); Assert.Equal(expected, actual); }
public void MatchConstructorArgumentAgainstReadOnlyProperty( string propertyName, string parameterName, bool expected) { var prop = new PropertyInfoElement( typeof(Version).GetProperty(propertyName)); var param = new ParameterInfoElement( typeof(Version) .GetConstructor(new[] { typeof(int), typeof(int) }) .GetParameters() .Where(p => p.Name == parameterName) .Single()); var actual = new SemanticElementComparer(new SemanticReflectionVisitor()) .Equals(prop, param); Assert.Equal(expected, actual); }
public virtual IReflectionVisitor <T> Visit(ParameterInfoElement parameterInfoElement) { return(OnVisitParameterInfoElement(parameterInfoElement)); }
private string ParametersFilename(ParameterInfoElement[] parameters) { string result = string.Join(",", parameters.Select(p => FilenamePartForParameter(p.ParameterType))); if (result.Length > 100) { // prevent too long filenames result = GetMD5Hash(result); } return result; }