Skip to content

Commit

Permalink
Fix macOS 10.13 test failures (#3066)
Browse files Browse the repository at this point in the history
  • Loading branch information
chamons authored and spouliot committed Dec 4, 2017
1 parent 113e518 commit 4c966e3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 29 deletions.
18 changes: 6 additions & 12 deletions tests/monotouch-test/CoreBluetooth/UuidTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ public void Roundtrip_16bits ()
using (CBUUID uuid = CBUUID.FromString ("1234")) {
Assert.That (uuid.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
Assert.IsNotNull (uuid.Data, "Data");
#if MONOMAC
var expected = "Unknown (<1234>)";
#else
var expected = UIDevice.CurrentDevice.CheckSystemVersion (7, 1) ? "1234" : "Unknown (<1234>)";
#endif
Assert.That (uuid.Description, Is.EqualTo (expected), "Description");
var firstExpected = "Unknown (<1234>)";
var secondExpected = "1234";
Assert.That (uuid.Description, Is.EqualTo (firstExpected).Or.EqualTo (secondExpected), "Description");
Assert.That (uuid.ToString (false), Is.EqualTo ("1234"), "ToString(false)");
Assert.That (uuid.ToString (true), Is.EqualTo ("00001234-0000-1000-8000-00805f9b34fb"), "ToString(true)");
using (CBUUID u2 = CBUUID.FromString (uuid.ToString ())) {
Expand All @@ -59,12 +56,9 @@ public void Roundtrip_128bits ()
using (CBUUID uuid = CBUUID.FromString ("12345678-90AB-CDEF-cafe-c80c20443d0b")) {
Assert.That (uuid.Handle, Is.Not.EqualTo (IntPtr.Zero), "Handle");
Assert.IsNotNull (uuid.Data, "Data");
#if MONOMAC
var expected = "Unknown (<12345678 90abcdef cafec80c 20443d0b>)";
#else
var expected = UIDevice.CurrentDevice.CheckSystemVersion (7, 1) ? "12345678-90AB-CDEF-CAFE-C80C20443D0B" : "Unknown (<12345678 90abcdef cafec80c 20443d0b>)";
#endif
Assert.That (uuid.Description, Is.EqualTo (expected), "Description");
var firstExpected = "Unknown (<12345678 90abcdef cafec80c 20443d0b>)";
var secondExpected = "12345678-90AB-CDEF-CAFE-C80C20443D0B";
Assert.That (uuid.Description, Is.EqualTo (firstExpected).Or.EqualTo (secondExpected), "Description");
Assert.That (uuid.ToString (false), Is.EqualTo (uuid.ToString (true)), "ToString");
using (CBUUID u2 = CBUUID.FromString (uuid.ToString ())) {
Assert.That (u2.ToString (), Is.EqualTo (uuid.ToString ()), "Roundtrip");
Expand Down
25 changes: 12 additions & 13 deletions tests/monotouch-test/Security/KeyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,19 @@ public void RoundtripRSAMinPKCS1 ()
byte [] cipher;
if (TestRuntime.CheckXcodeVersion (8,0)) {
Assert.True (public_key.IsAlgorithmSupported (SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Encrypt");
#if MONOMAC
Assert.False (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Decrypt");
Action<bool> decryptTest = v => {
Assert.That (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), Is.EqualTo (v), "public/IsAlgorithmSupported/Decrypt");
using (var pub = public_key.GetPublicKey ()) {
Assert.That (pub.Handle, Is.EqualTo (public_key.Handle), "public/GetPublicKey");
}
using (var pub = public_key.GetPublicKey ())
{
// a new native instance of the key is returned (so having a new managed SecKey is fine)
Assert.That (pub.Handle == public_key.Handle, Is.Not.EqualTo (v), "public/GetPublicKey");
}
};
#if MONOMAC
decryptTest (TestRuntime.CheckMacSystemVersion (10, 13));
#else
// I would have expect false
Assert.True (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Decrypt");

using (var pub = public_key.GetPublicKey ()) {
// a new native instance of the key is returned (so having a new managed SecKey is fine)
Assert.That (pub.Handle, Is.Not.EqualTo (public_key.Handle), "public/GetPublicKey");
}
decryptTest (true);
#endif
using (var attrs = public_key.GetAttributes ()) {
Assert.That (attrs.Count, Is.GreaterThan (0), "public/GetAttributes");
Expand Down Expand Up @@ -214,7 +213,7 @@ public void RoundtripRSA1024OAEP ()
Assert.True (public_key.IsAlgorithmSupported (SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "public/IsAlgorithmSupported/Encrypt");
// I would have expect false
#if MONOMAC
Assert.False (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "public/IsAlgorithmSupported/Decrypt");
Assert.That (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), Is.EqualTo (TestRuntime.CheckMacSystemVersion (10, 13)), "public/IsAlgorithmSupported/Decrypt");
#else
Assert.True (public_key.IsAlgorithmSupported (SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "public/IsAlgorithmSupported/Decrypt");
#endif
Expand Down
2 changes: 1 addition & 1 deletion tests/monotouch-test/SpriteKit/SpriteNodeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void Color ()
{
using (var n = new SKSpriteNode (UIColor.Blue, SizeF.Empty)) {
#if MONOMAC
Assert.That (n.Color.ToString (), Is.EqualTo ("Device RGB(0.016804177314043,0.198350995779037,1,1)"), "Color-1");
Assert.That (n.Color.ToString (), Is.EqualTo ("Device RGB(0.016804177314043,0.198350995779037,1,1)").Or.EqualTo ("Device RGB(0,0,1,1)"), "Color-1");
#else
Assert.That (n.Color.ToString (), Is.EqualTo ("UIColor [A=255, R=0, G=0, B=255]"), "Color-1");
#endif
Expand Down
3 changes: 0 additions & 3 deletions tests/xammac_tests/xammac_tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,6 @@
<Compile Include="..\monotouch-test\ObjCRuntime\RegistrarTest.cs">
<Link>ObjCRuntime\RegistrarTest.cs</Link>
</Compile>
<Compile Include="..\api-shared\ObjCRuntime\Registrar.cs">
<Link>api-shared\ObjCRuntime\Registrar.cs</Link>
</Compile>
<Compile Include="..\api-shared\ObjCRuntime\RegistrarTest.cs">
<Link>api-shared\ObjCRuntime\RegistrarTest.cs</Link>
</Compile>
Expand Down

0 comments on commit 4c966e3

Please sign in to comment.