public void SutIsGuardClauseCommand() { // Fixture setup var dummyOwner = new PropertyHolder<object>(); var dummyProperty = dummyOwner.GetType().GetProperty("Property"); // Exercise system var sut = new PropertySetCommand(dummyProperty, dummyOwner); // Verify outcome Assert.IsAssignableFrom<IGuardClauseCommand>(sut); // Teardown }
public void RequestedTypeIsCorrect() { // Fixture setup var dummyOwner = new PropertyHolder<Version>(); var property = dummyOwner.GetType().GetProperty("Property"); var sut = new PropertySetCommand(property, dummyOwner); // Exercise system var result = sut.RequestedType; // Verify outcome Assert.Equal(property.PropertyType, result); // Teardown }
public void OwnerIsCorrect() { // Fixture setup var owner = new PropertyHolder<object>(); var dummyProperty = owner.GetType().GetProperty("Property"); var sut = new PropertySetCommand(dummyProperty, owner); // Exercise system var result = sut.Owner; // Verify outcome Assert.Equal(owner, result); // Teardown }
public void PropertyInfoIsCorrect() { // Fixture setup var dummyOwner = new PropertyHolder<object>(); var propertyInfo = dummyOwner.GetType().GetProperty("Property"); var sut = new PropertySetCommand(propertyInfo, dummyOwner); // Exercise system PropertyInfo result = sut.PropertyInfo; // Verify outcome Assert.Equal(propertyInfo, result); // Teardown }
public void ExecuteAssignsValueToOwnerProperty() { // Fixture setup var owner = new PropertyHolder<object>(); var property = owner.GetType().GetProperty("Property"); var sut = new PropertySetCommand(property, owner); var value = new object(); // Exercise system sut.Execute(value); // Verify outcome Assert.Equal(value, owner.Property); // Teardown }
/// <summary> /// Verifies that a property has appripriate Guard Clauses in place. /// </summary> /// <param name="propertyInfo">The property.</param> /// <remarks> /// <para> /// Exactly which Guard Clauses are verified is defined by /// <see cref="BehaviorExpectation" />. /// </para> /// </remarks> public override void Verify(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException("propertyInfo"); } if (propertyInfo.GetSetMethod() == null) { return; } var owner = this.Builder.CreateAnonymous(propertyInfo.ReflectedType); var command = new PropertySetCommand(propertyInfo, owner); var unwrapper = new ReflectionExceptionUnwrappingCommand(command); this.BehaviorExpectation.Verify(unwrapper); }
/// <summary> /// Verifies that a property has appropriate Guard Clauses in place. /// </summary> /// <param name="propertyInfo">The property.</param> /// <remarks> /// <para> /// Exactly which Guard Clauses are verified is defined by /// <see cref="BehaviorExpectation" />. /// </para> /// </remarks> public override void Verify(PropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException("propertyInfo"); } if (propertyInfo.GetSetMethod() == null) { return; } propertyInfo = this.ResolveUnclosedGenericType(propertyInfo); var owner = this.CreateOwner(propertyInfo); var command = new PropertySetCommand(propertyInfo, owner); var unwrapper = new ReflectionExceptionUnwrappingCommand(command); this.BehaviorExpectation.Verify(unwrapper); }
/// <summary> /// Verifies that a property has appripriate Guard Clauses in place. /// </summary> /// <param name="propertyInfo">The property.</param> /// <remarks> /// <para> /// Exactly which Guard Clauses are verified is defined by /// <see cref="BehaviorExpectation" />. /// </para> /// </remarks> public override void Verify(PropertyInfo propertyInfo) { if (propertyInfo == null) throw new ArgumentNullException("propertyInfo"); if (propertyInfo.GetSetMethod() == null) return; var owner = this.Builder.CreateAnonymous(propertyInfo.ReflectedType); var command = new PropertySetCommand(propertyInfo, owner); var unwrapper = new ReflectionExceptionUnwrappingCommand(command); this.BehaviorExpectation.Verify(unwrapper); }
public void CreateExceptionWithInnerReturnsExceptionWithCorrectMessage() { // Fixture setup var dummyOwner = new PropertyHolder<Version>(); var dummyProperty = dummyOwner.GetType().GetProperty("Property"); var sut = new PropertySetCommand(dummyProperty, dummyOwner); // Exercise system var message = Guid.NewGuid().ToString(); var inner = new Exception(); var result = sut.CreateException(message, inner); // Verify outcome var e = Assert.IsAssignableFrom<GuardClauseException>(result); Assert.Contains(message, e.Message); // Teardown }