Author: spouliot
Date: 2008-02-15 14:17:14 -0500 (Fri, 15 Feb 2008)
New Revision: 95793
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/ChangeLog
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/MarshalStringsInPInvokeDeclarationsTest.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/PInvokeShouldNotBeVisibleTest.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/UseManagedAlternativesToPInvokeTest.cs
Log:
2008-02-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
* MarshalStringsInPInvokeDeclarationsTest.cs
* PInvokeShouldNotBeVisibleTest.cs
* UseManagedAlternativesToPInvokeTest.cs:
Update unit tests wrt framework changes.
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/ChangeLog
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/ChangeLog
2008-02-15 19:13:46 UTC (rev 95792)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/ChangeLog
2008-02-15 19:17:14 UTC (rev 95793)
@@ -1,3 +1,11 @@
+2008-02-15 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
+ * MarshalStringsInPInvokeDeclarationsTest.cs
+ * PInvokeShouldNotBeVisibleTest.cs
+ * UseManagedAlternativesToPInvokeTest.cs:
+ Update unit tests wrt framework changes.
+
2008-01-30 Sebastien Pouliot <[EMAIL PROTECTED]>
* GetLastErrorMustBeCalledRightAfterPInvokeTest.cs: More unit
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
2008-02-15 19:13:46 UTC (rev 95792)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/GetLastErrorMustBeCalledRightAfterPInvokeTest.cs
2008-02-15 19:17:14 UTC (rev 95793)
@@ -43,6 +43,7 @@
private GetLastErrorMustBeCalledRightAfterPInvokeRule rule;
private AssemblyDefinition assembly;
private TypeDefinition type;
+ private TestRunner runner;
[DllImport ("User32.dll")]
static extern Boolean MessageBeep (UInt32 beepType);
@@ -124,6 +125,7 @@
assembly = AssemblyFactory.GetAssembly (unit);
type = assembly.MainModule.Types
["Test.Rules.Interoperability.GetLastErrorMustBeCalledRightAfterPInvokeTest"];
rule = new
GetLastErrorMustBeCalledRightAfterPInvokeRule ();
+ runner = new TestRunner (rule);
}
private MethodDefinition GetTest (string name)
@@ -139,70 +141,70 @@
public void TestNothing ()
{
MethodDefinition method = GetTest ("CallNothing");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestNothingNotExternal ()
{
MethodDefinition method = GetTest
("CallNothingNotExternal");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke ()
{
MethodDefinition method = GetTest ("CallPInvoke");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError_valid ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError_valid");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError_invalid ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError_invalid");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError_invalid_newobj ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError_invalid_newobj");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError_invalid_struct ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError_invalid_struct");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestPInvoke_GetError_valid_struct ()
{
MethodDefinition method = GetTest
("CallPInvoke_GetError_valid_struct");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestGetError ()
{
MethodDefinition method = GetTest ("CallGetError");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
public void CallPInvoke_Branch ()
@@ -219,7 +221,7 @@
public void TestPInvoke_Branch ()
{
MethodDefinition method = GetTest
("CallPInvoke_Branch");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
public void CallPInvoke_Switch ()
@@ -240,7 +242,7 @@
public void TestPInvoke_Switch ()
{
MethodDefinition method = GetTest
("CallPInvoke_Switch");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
public void CallPInvoke_Endless ()
@@ -255,7 +257,7 @@
public void TestPInvoke_Endless ()
{
MethodDefinition method = GetTest
("CallPInvoke_Endless");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
public void TwoPInvokes ()
@@ -269,7 +271,7 @@
public void TestTwoPInvokes ()
{
MethodDefinition method = GetTest ("TwoPInvokes");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
}
}
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/MarshalStringsInPInvokeDeclarationsTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/MarshalStringsInPInvokeDeclarationsTest.cs
2008-02-15 19:13:46 UTC (rev 95792)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/MarshalStringsInPInvokeDeclarationsTest.cs
2008-02-15 19:17:14 UTC (rev 95793)
@@ -44,6 +44,7 @@
private MarshalStringsInPInvokeDeclarationsRule rule;
private AssemblyDefinition assembly;
private TypeDefinition type;
+ private TestRunner runner;
// checks for CharSet property
[DllImport ("kernel32")]
@@ -141,6 +142,7 @@
assembly = AssemblyFactory.GetAssembly (unit);
type = assembly.MainModule.Types
["Test.Rules.Interoperability.MarshalStringsInPInvokeDeclarationsTest"];
rule = new MarshalStringsInPInvokeDeclarationsRule ();
+ runner = new TestRunner (rule);
}
private MethodDefinition GetTest (string name)
@@ -156,65 +158,63 @@
public void TestEmptyMethod ()
{
MethodDefinition method = GetTest ("EmptyMethod");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.DoesNotApply,
runner.CheckMethod (method));
}
[Test]
public void TestNoStringsMethod ()
{
MethodDefinition method = GetTest ("Sleep");
- MessageCollection messages = rule.CheckMethod (method,
new MinimalRunner ());
- Assert.IsNull (messages);
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestStringWithCharsetMethod ()
{
MethodDefinition method = GetTest ("FindFirstFile");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestStringBuilderWithCharsetMethod ()
{
MethodDefinition method = GetTest ("GetUserNameEx");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestStringWithoutCharsetMethod ()
{
MethodDefinition method = GetTest ("PlaySound");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestStringBuilderWithoutCharsetMethod ()
{
MethodDefinition method = GetTest ("MessageBox");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestDeclarationWithMarshalAs ()
{
MethodDefinition method = GetTest
("GetShortPathNameGood");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestDeclarationWithoutMarshalAsCharsetSpec ()
{
MethodDefinition method = GetTest
("GetShortPathNameBadParametersCharsetSpec");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestDeclarationWithoutMarshalAsCharsetNotSpec ()
{
MethodDefinition method = GetTest
("GetShortPathNameBadParametersCharsetNotSpec");
- MessageCollection messages = rule.CheckMethod (method,
new MinimalRunner ());
- Assert.IsNotNull (messages);
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
}
}
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/PInvokeShouldNotBeVisibleTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/PInvokeShouldNotBeVisibleTest.cs
2008-02-15 19:13:46 UTC (rev 95792)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/PInvokeShouldNotBeVisibleTest.cs
2008-02-15 19:17:14 UTC (rev 95793)
@@ -72,6 +72,7 @@
public class PInvokeShouldNotBeVisibleRuleTest {
private PInvokeShouldNotBeVisibleRule rule;
+ private TestRunner runner;
private AssemblyDefinition assembly;
private TypeDefinition internalType;
private TypeDefinition publicType;
@@ -91,6 +92,7 @@
publicType_PublicNested = assembly.MainModule.Types
["Test.Rules.Interoperability.PInvokePublic"].NestedTypes [0];
publicType_InternalNested = assembly.MainModule.Types
["Test.Rules.Interoperability.PInvokePublic"].NestedTypes [1];
rule = new PInvokeShouldNotBeVisibleRule ();
+ runner = new TestRunner (rule);
}
private MethodDefinition GetTest (TypeDefinition type, string
name)
@@ -106,49 +108,49 @@
public void TestInternal_Internal ()
{
MethodDefinition method = GetTest (internalType,
"MessageBeepInternal");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestInternal_Public ()
{
MethodDefinition method = GetTest (internalType,
"MessageBeepPublic");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestInternal_PublicNested()
{
MethodDefinition method = GetTest
(internalType_PublicNested, "MessageBeepPublic");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPublic_Internal ()
{
MethodDefinition method = GetTest (publicType,
"MessageBeepInternal");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void TestPublic_Public ()
{
MethodDefinition method = GetTest (publicType,
"MessageBeepPublic");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestPublic_PublicNested ()
{
MethodDefinition method = GetTest
(publicType_PublicNested, "MessageBeepPublic");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
- public void TestPublic_InernalNested ()
+ public void TestPublic_InternalNested ()
{
MethodDefinition method = GetTest
(publicType_InternalNested, "MessageBeepPublic");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
}
}
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/UseManagedAlternativesToPInvokeTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/UseManagedAlternativesToPInvokeTest.cs
2008-02-15 19:13:46 UTC (rev 95792)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Interoperability/Test/UseManagedAlternativesToPInvokeTest.cs
2008-02-15 19:17:14 UTC (rev 95793)
@@ -45,6 +45,7 @@
private UseManagedAlternativesToPInvokeRule rule;
private AssemblyDefinition assembly;
private TypeDefinition type;
+ private TestRunner runner;
[DllImport ("kernel32")]
static extern void Sleep (uint time); // bad because we have
Thread.Sleep ()
@@ -65,6 +66,7 @@
assembly = AssemblyFactory.GetAssembly (unit);
type = assembly.MainModule.Types
["Test.Rules.Interoperability.UseManagedAlternativesToPInvokeTest"];
rule = new UseManagedAlternativesToPInvokeRule ();
+ runner = new TestRunner (rule);
}
private MethodDefinition GetTest (string name)
@@ -80,32 +82,28 @@
public void TestEmptyMethod ()
{
MethodDefinition method = GetTest ("EmptyMethod");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.DoesNotApply,
runner.CheckMethod (method));
}
[Test]
public void TestBadMethod ()
{
MethodDefinition method = GetTest ("Sleep");
- MessageCollection messages = rule.CheckMethod (method,
new MinimalRunner ());
- Assert.IsNotNull (messages);
- Assert.AreEqual (1, messages.Count);
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestBadMethodMultipleSolutions ()
{
MethodDefinition method = GetTest ("FindFirstFile");
- MessageCollection messages = rule.CheckMethod (method,
new MinimalRunner ());
- Assert.IsNotNull (messages);
- Assert.AreEqual (1, messages.Count);
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
[Test]
public void TestOkMethod ()
{
MethodDefinition method = GetTest ("MessageBeep");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches