public void TestProperties() { // Test field property using (var prop = new TestProperties()) { Assert.That(prop.Field, Is.EqualTo(0)); prop.Field = 10; Assert.That(prop.Field, Is.EqualTo(10)); // Test getter/setter property prop.Field = 20; Assert.That(prop.FieldValue, Is.EqualTo(20)); prop.FieldValue = 10; Assert.That(prop.FieldValue, Is.EqualTo(10)); prop.GetterAndSetterWithTheSameName = 25; Assert.That(prop.GetterAndSetterWithTheSameName, Is.EqualTo(25)); prop.SetterReturnsBoolean = 35; Assert.That(prop.SetterReturnsBoolean, Is.EqualTo(35)); Assert.That(prop.SetSetterReturnsBoolean(35), Is.False); Assert.That(prop.SetSetterReturnsBoolean(40), Is.True); prop.VirtualSetterReturnsBoolean = 45; Assert.That(prop.VirtualSetterReturnsBoolean, Is.EqualTo(45)); Assert.That(prop.SetVirtualSetterReturnsBoolean(45), Is.False); Assert.That(prop.SetVirtualSetterReturnsBoolean(50), Is.True); Assert.That(prop.nestedEnum(), Is.EqualTo(5)); Assert.That(prop.nestedEnum(55), Is.EqualTo(55)); Assert.That(prop.Get32Bit, Is.EqualTo(10)); Assert.That(prop.ConstRefField, Is.EqualTo(prop.Field)); Assert.That(prop.IsEmpty, Is.EqualTo(prop.Empty)); Assert.That(prop.VirtualGetter, Is.EqualTo(15)); Assert.That(prop.StartWithVerb, Is.EqualTo(25)); prop.StartWithVerb = 5; Assert.That(prop.Contains('a'), Is.EqualTo(prop.Contains("a"))); Assert.That(prop.conflict, Is.EqualTo(CommonTest.TestProperties.Conflict.Value1)); prop.conflict = CommonTest.TestProperties.Conflict.Value2; Assert.That(prop.conflict, Is.EqualTo(CommonTest.TestProperties.Conflict.Value2)); prop.Callback = x => 4 * x; Assert.That(prop.Callback(5), Is.EqualTo(20)); Assert.That(prop.ArchiveName, Is.EqualTo(20)); } using (var prop = new HasOverridenSetter()) { Assert.That(prop.VirtualGetter, Is.EqualTo(20)); prop.SetVirtualGetter(5); } }