diff options
author | Jb Evain <jbevain@gmail.com> | 2014-05-26 20:01:14 +0400 |
---|---|---|
committer | Jb Evain <jbevain@gmail.com> | 2014-05-27 13:43:46 +0400 |
commit | b0d207835e9b1f33d03dce668cad2a2356249456 (patch) | |
tree | c2b48090c2c99b17b73357c2d9fdede5788604d0 /Test/Mono.Cecil.Tests/PropertyTests.cs | |
parent | 0c5b096369b462dbe71a6fe717d96c944f1122c1 (diff) |
Port nunit addin to simple tests
Diffstat (limited to 'Test/Mono.Cecil.Tests/PropertyTests.cs')
-rw-r--r-- | Test/Mono.Cecil.Tests/PropertyTests.cs | 136 |
1 files changed, 72 insertions, 64 deletions
diff --git a/Test/Mono.Cecil.Tests/PropertyTests.cs b/Test/Mono.Cecil.Tests/PropertyTests.cs index 2ff9c92..32ffa50 100644 --- a/Test/Mono.Cecil.Tests/PropertyTests.cs +++ b/Test/Mono.Cecil.Tests/PropertyTests.cs @@ -7,106 +7,114 @@ namespace Mono.Cecil.Tests { [TestFixture] public class PropertyTests : BaseTestFixture { - [TestCSharp ("Properties.cs")] - public void AbstractMethod (ModuleDefinition module) + [Test] + public void AbstractMethod () { - var type = module.GetType ("Foo"); + TestCSharp ("Properties.cs", module => { + var type = module.GetType ("Foo"); - Assert.IsTrue (type.HasProperties); + Assert.IsTrue (type.HasProperties); - var properties = type.Properties; + var properties = type.Properties; - Assert.AreEqual (3, properties.Count); + Assert.AreEqual (3, properties.Count); - var property = properties [0]; + var property = properties [0]; - Assert.IsNotNull (property); - Assert.AreEqual ("Bar", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.Int32", property.PropertyType.FullName); + Assert.IsNotNull (property); + Assert.AreEqual ("Bar", property.Name); + Assert.IsNotNull (property.PropertyType); + Assert.AreEqual ("System.Int32", property.PropertyType.FullName); - Assert.IsNotNull (property.GetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); - Assert.IsNull (property.SetMethod); + Assert.IsNotNull (property.GetMethod); + Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); + Assert.IsNull (property.SetMethod); - property = properties [1]; + property = properties [1]; - Assert.IsNotNull (property); - Assert.AreEqual ("Baz", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); + Assert.IsNotNull (property); + Assert.AreEqual ("Baz", property.Name); + Assert.IsNotNull (property.PropertyType); + Assert.AreEqual ("System.String", property.PropertyType.FullName); - Assert.IsNotNull (property.GetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); - Assert.IsNotNull (property.SetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); + Assert.IsNotNull (property.GetMethod); + Assert.AreEqual (MethodSemanticsAttributes.Getter, property.GetMethod.SemanticsAttributes); + Assert.IsNotNull (property.SetMethod); + Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); - property = properties [2]; + property = properties [2]; - Assert.IsNotNull (property); - Assert.AreEqual ("Gazonk", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); + Assert.IsNotNull (property); + Assert.AreEqual ("Gazonk", property.Name); + Assert.IsNotNull (property.PropertyType); + Assert.AreEqual ("System.String", property.PropertyType.FullName); - Assert.IsNull (property.GetMethod); - Assert.IsNotNull (property.SetMethod); - Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); + Assert.IsNull (property.GetMethod); + Assert.IsNotNull (property.SetMethod); + Assert.AreEqual (MethodSemanticsAttributes.Setter, property.SetMethod.SemanticsAttributes); + }); } - [TestIL ("others.il")] - public void OtherMethod (ModuleDefinition module) + [Test] + public void OtherMethod () { - var type = module.GetType ("Others"); + TestIL ("others.il", module => { + var type = module.GetType ("Others"); - Assert.IsTrue (type.HasProperties); + Assert.IsTrue (type.HasProperties); - var properties = type.Properties; + var properties = type.Properties; - Assert.AreEqual (1, properties.Count); + Assert.AreEqual (1, properties.Count); - var property = properties [0]; + var property = properties [0]; - Assert.IsNotNull (property); - Assert.AreEqual ("Context", property.Name); - Assert.IsNotNull (property.PropertyType); - Assert.AreEqual ("System.String", property.PropertyType.FullName); + Assert.IsNotNull (property); + Assert.AreEqual ("Context", property.Name); + Assert.IsNotNull (property.PropertyType); + Assert.AreEqual ("System.String", property.PropertyType.FullName); - Assert.IsTrue (property.HasOtherMethods); + Assert.IsTrue (property.HasOtherMethods); - Assert.AreEqual (2, property.OtherMethods.Count); + Assert.AreEqual (2, property.OtherMethods.Count); - var other = property.OtherMethods [0]; - Assert.AreEqual ("let_Context", other.Name); + var other = property.OtherMethods [0]; + Assert.AreEqual ("let_Context", other.Name); - other = property.OtherMethods [1]; - Assert.AreEqual ("bet_Context", other.Name); + other = property.OtherMethods [1]; + Assert.AreEqual ("bet_Context", other.Name); + }); } - [TestCSharp ("Properties.cs")] - public void SetOnlyIndexer (ModuleDefinition module) + [Test] + public void SetOnlyIndexer () { - var type = module.GetType ("Bar"); - var indexer = type.Properties.Where (property => property.Name == "Item").First (); + TestCSharp ("Properties.cs", module => { + var type = module.GetType ("Bar"); + var indexer = type.Properties.Where (property => property.Name == "Item").First (); - var parameters = indexer.Parameters; + var parameters = indexer.Parameters; - Assert.AreEqual (2, parameters.Count); - Assert.AreEqual ("System.Int32", parameters [0].ParameterType.FullName); - Assert.AreEqual ("System.String", parameters [1].ParameterType.FullName); + Assert.AreEqual (2, parameters.Count); + Assert.AreEqual ("System.Int32", parameters [0].ParameterType.FullName); + Assert.AreEqual ("System.String", parameters [1].ParameterType.FullName); + }); } - [TestCSharp ("Properties.cs")] - public void ReadSemanticsFirst (ModuleDefinition module) + [Test] + public void ReadSemanticsFirst () { - var type = module.GetType ("Baz"); - var setter = type.GetMethod ("set_Bingo"); + TestCSharp ("Properties.cs", module => { + var type = module.GetType ("Baz"); + var setter = type.GetMethod ("set_Bingo"); - Assert.AreEqual (MethodSemanticsAttributes.Setter, setter.SemanticsAttributes); + Assert.AreEqual (MethodSemanticsAttributes.Setter, setter.SemanticsAttributes); - var property = type.Properties.Where (p => p.Name == "Bingo").First (); + var property = type.Properties.Where (p => p.Name == "Bingo").First (); - Assert.AreEqual (setter, property.SetMethod); - Assert.AreEqual (type.GetMethod ("get_Bingo"), property.GetMethod); + Assert.AreEqual (setter, property.SetMethod); + Assert.AreEqual (type.GetMethod ("get_Bingo"), property.GetMethod); + }); } } } |