avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1562161 - in /avro/trunk: CHANGES.txt lang/csharp/src/apache/test/Specific/SpecificTests.cs
Date Tue, 28 Jan 2014 19:17:11 GMT
Author: cutting
Date: Tue Jan 28 19:17:10 2014
New Revision: 1562161

URL: http://svn.apache.org/r1562161
Log:
AVRO-1436. C#: Fix tests to run multiple times.  Contributed by David Taylor.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/csharp/src/apache/test/Specific/SpecificTests.cs

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1562161&r1=1562160&r2=1562161&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Jan 28 19:17:10 2014
@@ -16,6 +16,8 @@ Trunk (not yet released)
     AVRO-1445. Java: Fix protobuf support to correctly handle enums
     with default values.  (cutting)
 
+    AVRO-1436. C#: Fix tests to run multiple times. (David Taylor via cutting)
+
 Avro 1.7.6 (15 January 2014)
 
   NEW FEATURES

Modified: avro/trunk/lang/csharp/src/apache/test/Specific/SpecificTests.cs
URL: http://svn.apache.org/viewvc/avro/trunk/lang/csharp/src/apache/test/Specific/SpecificTests.cs?rev=1562161&r1=1562160&r2=1562161&view=diff
==============================================================================
--- avro/trunk/lang/csharp/src/apache/test/Specific/SpecificTests.cs (original)
+++ avro/trunk/lang/csharp/src/apache/test/Specific/SpecificTests.cs Tue Jan 28 19:17:10 2014
@@ -30,7 +30,14 @@ namespace Avro.Test
 {
     [TestFixture]
     class SpecificTests
-    {
+    {
+        // The dynamically created assembly used in the test below can only be created
+        // once otherwise repeated tests will fail as the same type name will exist in
+        // multiple assemblies and so the type in the test and the type found by ObjectCreator
+        // will differ.  This single CompilerResults only works so long as there is only
one test.
+        // If additional tests are added then each test will need its own CompilerResults.
+        private static CompilerResults compres;
+
         [TestCase(@"{
   ""protocol"" : ""MyProtocol"",
   ""namespace"" : ""com.foo"",
@@ -154,6 +161,8 @@ namespace Avro.Test
 )]
         public void TestSpecific(string str, object[] result)
         {
+            if(compres == null)
+            {
             Protocol protocol = Protocol.Parse(str);
             var codegen = new CodeGen();
             codegen.AddProtocol(protocol);
@@ -186,14 +195,15 @@ namespace Avro.Test
             comparam.GenerateInMemory = true;
             var ccp = new Microsoft.CSharp.CSharpCodeProvider();
             var units = new CodeCompileUnit[] { compileUnit };
-            var compres = ccp.CompileAssemblyFromDom(comparam, units);
-            if (compres == null || compres.Errors.Count > 0)
+            compres = ccp.CompileAssemblyFromDom(comparam, units);
+            Assert.IsNotNull(compres);
+            if (compres.Errors.Count > 0)
             {
                 for (int i = 0; i < compres.Errors.Count; i++)
                     Console.WriteLine(compres.Errors[i]);
             }
-            if (null != compres)
-                Assert.IsTrue(compres.Errors.Count == 0);
+            Assert.IsTrue(compres.Errors.Count == 0);
+            }
 
             // create record
             ISpecificRecord rec = compres.CompiledAssembly.CreateInstance((string)result[1])
as ISpecificRecord;



Mime
View raw message