Skip to content

Instantly share code, notes, and snippets.

@jnericks
Created February 10, 2011 20:35
Show Gist options
  • Save jnericks/821281 to your computer and use it in GitHub Desktop.
Save jnericks/821281 to your computer and use it in GitHub Desktop.
using Machine.Specifications;
using Machine.Specifications.DevelopWithPassion.Rhino;
namespace Specs
{
public class TestSpecs
{
public abstract class concern : Observes
{
Establish c = () =>
{
fake_with_private_setter = an<PrivateSetter>();
real_with_private_setter = new PrivateSetter();
fake_with_protected_setter = an<ProtectedSetter>();
real_with_protected_setter = new ProtectedSetter();
};
protected static PrivateSetter fake_with_private_setter;
protected static PrivateSetter real_with_private_setter;
protected static ProtectedSetter fake_with_protected_setter;
protected static ProtectedSetter real_with_protected_setter;
}
public class when_setting_value_on_fake_with_private_setter : concern
{
Because of = () =>
typeof(PrivateSetter).GetProperty("TheProperty").SetValue(fake_with_private_setter, true, null);
// fail
It should_succeed = () =>
fake_with_private_setter.TheProperty.ShouldBeTrue();
}
public class when_setting_value_on_real_with_private_setter : concern
{
Because of = () =>
typeof(PrivateSetter).GetProperty("TheProperty").SetValue(real_with_private_setter, true, null);
// pass
It should_succeed = () =>
real_with_private_setter.TheProperty.ShouldBeTrue();
}
public class when_setting_value_on_fake_with_protected_setter : concern
{
Because of = () =>
typeof(ProtectedSetter).GetProperty("TheProperty").SetValue(fake_with_protected_setter, true, null);
// pass
It should_succeed = () =>
fake_with_protected_setter.TheProperty.ShouldBeTrue();
}
public class when_setting_value_on_real_with_protected_setter : concern
{
Because of = () =>
typeof(ProtectedSetter).GetProperty("TheProperty").SetValue(real_with_protected_setter, true, null);
// pass
It should_succeed = () =>
real_with_protected_setter.TheProperty.ShouldBeTrue();
}
}
public class PrivateSetter
{
public virtual bool TheProperty { get; private set; }
}
public class ProtectedSetter
{
public virtual bool TheProperty { get; protected set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment