summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/test/src/asn1/test/GenerationTest.cs18
-rw-r--r--crypto/test/src/asn1/test/TimeTest.cs4
-rw-r--r--crypto/test/src/util/test/SimpleTest.cs18
3 files changed, 29 insertions, 11 deletions
diff --git a/crypto/test/src/asn1/test/GenerationTest.cs b/crypto/test/src/asn1/test/GenerationTest.cs
index 5acf8e149..862e66d22 100644
--- a/crypto/test/src/asn1/test/GenerationTest.cs
+++ b/crypto/test/src/asn1/test/GenerationTest.cs
@@ -53,8 +53,8 @@ namespace Org.BouncyCastle.Asn1.Tests
         private void TbsV1CertGenerate()
         {
 			V1TbsCertificateGenerator gen = new V1TbsCertificateGenerator();
-            DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 1);
-            DateTime endDate = new DateTime(1970, 1, 1, 0, 0, 12);
+            DateTime startDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 1);
+            DateTime endDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 12);
 
             gen.SetSerialNumber(new DerInteger(1));
 
@@ -106,8 +106,8 @@ namespace Org.BouncyCastle.Asn1.Tests
 		private void TbsV3CertGenerate()
         {
 			V3TbsCertificateGenerator gen = new V3TbsCertificateGenerator();
-			DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 1);
-			DateTime endDate = new DateTime(1970, 1, 1, 0, 0, 2);
+            DateTime startDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 1);
+            DateTime endDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 2);
 
 			gen.SetSerialNumber(new DerInteger(2));
 
@@ -166,8 +166,8 @@ namespace Org.BouncyCastle.Asn1.Tests
 		private void TbsV3CertGenWithNullSubject()
 		{
 			V3TbsCertificateGenerator gen = new V3TbsCertificateGenerator();
-			DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 1);
-			DateTime endDate = new DateTime(1970, 1, 1, 0, 0, 2);
+            DateTime startDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 1);
+            DateTime endDate = MakeUtcDateTime(1970, 1, 1, 0, 0, 2);
 
 			gen.SetSerialNumber(new DerInteger(2));
 
@@ -243,11 +243,11 @@ namespace Org.BouncyCastle.Asn1.Tests
 
             gen.SetIssuer(new X509Name("CN=AU,O=Bouncy Castle"));
 
-            gen.AddCrlEntry(new DerInteger(1), new Time(new DateTime(1970, 1, 1, 0, 0, 1)), ReasonFlags.AACompromise);
+            gen.AddCrlEntry(new DerInteger(1), new Time(MakeUtcDateTime(1970, 1, 1, 0, 0, 1)), ReasonFlags.AACompromise);
 
-            gen.SetNextUpdate(new Time(new DateTime(1970, 1, 1, 0, 0, 2)));
+            gen.SetNextUpdate(new Time(MakeUtcDateTime(1970, 1, 1, 0, 0, 2)));
 
-            gen.SetThisUpdate(new Time(new DateTime(1970, 1, 1, 0, 0, 0, 500)));
+            gen.SetThisUpdate(new Time(MakeUtcDateTime(1970, 1, 1, 0, 0, 0, 500)));
 
             gen.SetSignature(new AlgorithmIdentifier(PkcsObjectIdentifiers.Sha1WithRsaEncryption, DerNull.Instance));
 
diff --git a/crypto/test/src/asn1/test/TimeTest.cs b/crypto/test/src/asn1/test/TimeTest.cs
index 6f6bd6f2c..04dac3c9e 100644
--- a/crypto/test/src/asn1/test/TimeTest.cs
+++ b/crypto/test/src/asn1/test/TimeTest.cs
@@ -15,9 +15,9 @@ namespace Org.BouncyCastle.Asn1.Tests
 			DateTime now = DateTime.UtcNow;
 
 			// Time classes only have a resolution of seconds
-			now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
+			now = SimpleTest.MakeUtcDateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
 
-			Org.BouncyCastle.Asn1.Cms.Time cmsTime = new Org.BouncyCastle.Asn1.Cms.Time(now);
+            Org.BouncyCastle.Asn1.Cms.Time cmsTime = new Org.BouncyCastle.Asn1.Cms.Time(now);
 			Org.BouncyCastle.Asn1.X509.Time x509Time = new Org.BouncyCastle.Asn1.X509.Time(now);
 
 //			Assert.AreEqual(cmsTime.Date, x509Time.ToDateTime());
diff --git a/crypto/test/src/util/test/SimpleTest.cs b/crypto/test/src/util/test/SimpleTest.cs
index be846e20f..84a7ce02b 100644
--- a/crypto/test/src/util/test/SimpleTest.cs
+++ b/crypto/test/src/util/test/SimpleTest.cs
@@ -160,5 +160,23 @@ namespace Org.BouncyCastle.Utilities.Test
 		internal static readonly string NewLine = GetNewLine();
 
 		public abstract void PerformTest();
+
+        public static DateTime MakeUtcDateTime(int year, int month, int day, int hour, int minute, int second)
+        {
+#if PORTABLE
+            return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc);
+#else
+            return new DateTime(year, month, day, hour, minute, second);
+#endif
+        }
+
+        public static DateTime MakeUtcDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond)
+        {
+#if PORTABLE
+            return new DateTime(year, month, day, hour, minute, second, millisecond, DateTimeKind.Utc);
+#else
+            return new DateTime(year, month, day, hour, minute, second, millisecond);
+#endif
+        }
     }
 }