public void SetUp() { TestRuntime.AssertXcodeVersion(9, 0); descriptor = new MTLTileRenderPipelineColorAttachmentDescriptor(); }
public void Setup () => TestRuntime.AssertXcodeVersion (12, TestRuntime.MinorXcode12APIMismatch);
public void SetUp() { TestRuntime.AssertXcodeVersion(10, 0); }
private // Abort with Cancel failing in desktop too. so disabling test //[InlineData(true)] void AbortParallel(bool isTestCancel) { const int noBranches = 10; Variable <int> value = VariableHelper.Create <int>("value"); TestParallel parallel = new TestParallel() { Variables = { value }, ExpectedOutcome = Outcome.Faulted }; for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); TestSequence branchSequence = new TestSequence("Seq" + branchName) { Activities = { new TestWriteLine() { Message = branchName + " Started" }, new TestReadLine <int>(branchName, branchName) { BookmarkValue = value, ExpectedOutcome = Outcome.Faulted }, new TestWriteLine() { Message = branchName + " Completed", ExpectedOutcome = Outcome.Faulted }, }, ExpectedOutcome = Outcome.Faulted }; if (isTestCancel) { if (i == 0) { branchSequence.Activities[1].ExpectedOutcome = Outcome.Canceled; } } parallel.Branches.Add(branchSequence); } TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(parallel); runtime.ExecuteWorkflow(); runtime.WaitForIdle(); //Cancel Workflow if (isTestCancel) { //Log.Info("Cancelling Workflow"); runtime.CancelWorkflow(); runtime.WaitForCanceled(); } //Abort Workflow runtime.AbortWorkflow("Aborting for Test"); ExpectedTrace expectedTrace = parallel.GetExpectedTrace(); //Only verify User trace since activity traces will not be available once abort is called expectedTrace.AddVerifyTypes(typeof(UserTrace)); Exception excepion; runtime.WaitForAborted(out excepion, expectedTrace); }
public void SetUp() { TestRuntime.AssertXcodeVersion(6, 0); TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false); }
public void DisableMulticastLoopbackTest() { TestRuntime.AssertXcodeVersion(13, 0); Assert.DoesNotThrow(() => options.DisableMulticastLoopback(false)); }
public void TestStateChangesHandler() { // In the test we are doing the following: // // 1. Start a browser. At this point, we have no listeners (unless someone is exposing it in the lab) // and therefore the browser cannot find any services/listeners. // 2. Start a listener that is using the same type/domain pair that the browser expects. // 3. Browser picks up the new listener, and sends an event (service found). // 4. Listener stops, and the service disappears. // 5. The browser is not yet canceled, so it picks up that the service/listener is not longer then and returns it. // // The test will block until the different events are set by the callbacks that are executed in a diff thread. bool firstRun = true; bool eventsDone = false; bool listeningDone = false; Exception ex = null; var changesEvent = new AutoResetEvent(false); var browserReady = new AutoResetEvent(false); var finalEvent = new AutoResetEvent(false); TestRuntime.RunAsync(DateTime.Now.AddSeconds(30), async() => { // start the browser, before the listener browser.SetStateChangesHandler((st, er) => { Assert.IsNotNull(st, "State"); Assert.IsNull(er, "Error"); if (st == NWBrowserState.Ready) { browserReady.Set(); } }); browser.SetChangesHandler((oldResult, newResult) => { // first time, listener appears, so we do not have an old result, second time // listener goes, so we do not have a new result try { if (firstRun) { Assert.IsNull(oldResult, "oldResult first run."); Assert.IsNotNull(newResult, "newResult first run"); firstRun = false; } else { Assert.IsNotNull(oldResult, "oldResult first run."); Assert.IsNull(newResult, "newResult first run"); } } catch (Exception e) { ex = e; } finally { changesEvent.Set(); eventsDone = true; } }); browser.Start(); browserReady.WaitOne(30000); using (var advertiser = NWAdvertiseDescriptor.CreateBonjourService("MonoTouchFixtures.Network", type)) using (var tcpOptions = NWProtocolOptions.CreateTcp()) using (var tlsOptions = NWProtocolOptions.CreateTls()) using (var paramenters = NWParameters.CreateTcp()) { paramenters.ProtocolStack.PrependApplicationProtocol(tlsOptions); paramenters.ProtocolStack.PrependApplicationProtocol(tcpOptions); paramenters.IncludePeerToPeer = true; using (var listener = NWListener.Create("1234", paramenters)) { listener.SetQueue(DispatchQueue.CurrentQueue); listener.SetAdvertiseDescriptor(advertiser); // we need the connection handler, else we will get an exception listener.SetNewConnectionHandler((c) => { }); listener.SetStateChangedHandler((s, e) => { if (e != null) { Console.WriteLine($"Got error {e.ErrorCode} {e.ErrorDomain} '{e.CFError.FailureReason}' {e.ToString ()}"); } }); listener.Start(); changesEvent.WaitOne(30000); listener.Cancel(); listeningDone = true; finalEvent.Set(); } } }, () => eventsDone); finalEvent.WaitOne(30000); Assert.IsTrue(eventsDone); Assert.IsTrue(listeningDone); Assert.IsNull(ex, "Exception"); browser.Cancel(); }
public void ThrowException() { TestThrow <InvalidDataException> throwAct = new TestThrow <InvalidDataException>("Throw Invalid data"); TestRuntime.RunAndValidateAbortedException(throwAct, typeof(InvalidDataException), new Dictionary <string, string>()); }
public void Fields() { TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false); // just to confirm it's not an NSUrl but an NSString Assert.That(UIDocument.UserActivityDocumentUrlKey.ToString(), Is.EqualTo("NSUserActivityDocumentURL"), "NSUserActivityDocumentURLKey"); }
public void RoundtripRSAMinPKCS1() { NSError error; SecKey private_key; SecKey public_key; using (var record = new SecRecord(SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = MinRsaKeySize; // it's not a performance test :) Assert.That(SecKey.GenerateKeyPair(record.ToDictionary(), out public_key, out private_key), Is.EqualTo(SecStatusCode.Success), "GenerateKeyPair"); byte [] plain = new byte [20] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; byte [] cipher; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.True(public_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "public/IsAlgorithmSupported/Encrypt"); #if MONOMAC Assert.That(public_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), Is.EqualTo(TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 13)), "public/IsAlgorithmSupported/Decrypt"); using (var pub = public_key.GetPublicKey()) { // macOS behaviour is not consistent - but the test main goal is to check we get a key Assert.That(pub.Handle, Is.Not.EqualTo(IntPtr.Zero), "public/GetPublicKey"); } #else 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.False(pub.Handle == public_key.Handle, "public/GetPublicKey"); } #endif using (var attrs = public_key.GetAttributes()) { Assert.That(attrs.Count, Is.GreaterThan((nuint)0), "public/GetAttributes"); } using (var data = public_key.GetExternalRepresentation(out error)) { Assert.Null(error, "public/error-1"); Assert.NotNull(data, "public/GetExternalRepresentation"); using (var key = SecKey.Create(data, SecKeyType.RSA, SecKeyClass.Public, MinRsaKeySize, null, out error)) { Assert.Null(error, "public/Create/error-1"); } } } Assert.That(public_key.Encrypt(SecPadding.PKCS1, plain, out cipher), Is.EqualTo(SecStatusCode.Success), "Encrypt"); byte[] result; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.False(private_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "private/IsAlgorithmSupported/Encrypt"); Assert.True(private_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionPkcs1), "private/IsAlgorithmSupported/Decrypt"); #if MONOMAC using (var pub2 = private_key.GetPublicKey()) { Assert.That(pub2.Handle, Is.EqualTo(public_key.Handle), "private/GetPublicKey"); } #else using (var pub2 = private_key.GetPublicKey()) { // a new native instance of the key is returned (so having a new managed SecKey is fine) Assert.That(pub2.Handle, Is.Not.EqualTo(public_key.Handle), "private/GetPublicKey"); } #endif using (var attrs = private_key.GetAttributes()) { Assert.That(attrs.Count, Is.GreaterThan((nuint)0), "private/GetAttributes"); } using (var data2 = private_key.GetExternalRepresentation(out error)) { Assert.Null(error, "private/error-1"); Assert.NotNull(data2, "private/GetExternalRepresentation"); using (var key = SecKey.Create(data2, SecKeyType.RSA, SecKeyClass.Private, MinRsaKeySize, null, out error)) { Assert.Null(error, "private/Create/error-1"); } } } public_key.Dispose(); var expectedResult = SecStatusCode.Success; #if __MACOS__ if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 8)) { expectedResult = SecStatusCode.InvalidData; } #endif Assert.That(private_key.Decrypt(SecPadding.PKCS1, cipher, out result), Is.EqualTo(expectedResult), "Decrypt"); if (expectedResult != SecStatusCode.InvalidData) { Assert.That(plain, Is.EqualTo(result), "match"); } private_key.Dispose(); } }
public void SetUp() { TestRuntime.AssertXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch); functions = MTLLinkedFunctions.Create(); }
public void RoundtripRSA1024OAEP() { SecKey private_key; SecKey public_key; using (var record = new SecRecord(SecKind.Key)) { record.KeyType = SecKeyType.RSA; record.KeySizeInBits = 1024; // it's not a performance test :) Assert.That(SecKey.GenerateKeyPair(record.ToDictionary(), out public_key, out private_key), Is.EqualTo(SecStatusCode.Success), "GenerateKeyPair"); byte [] plain = new byte [0]; byte [] cipher; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.True(public_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "public/IsAlgorithmSupported/Encrypt"); // I would have expect false #if MONOMAC Assert.That(public_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), Is.EqualTo(TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 13)), "public/IsAlgorithmSupported/Decrypt"); #else Assert.True(public_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "public/IsAlgorithmSupported/Decrypt"); #endif } Assert.That(public_key.Encrypt(SecPadding.OAEP, plain, out cipher), Is.EqualTo(SecStatusCode.Success), "Encrypt"); public_key.Dispose(); byte[] result; if (TestRuntime.CheckXcodeVersion(8, 0)) { Assert.False(private_key.IsAlgorithmSupported(SecKeyOperationType.Encrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "private/IsAlgorithmSupported/Encrypt"); Assert.True(private_key.IsAlgorithmSupported(SecKeyOperationType.Decrypt, SecKeyAlgorithm.RsaEncryptionOaepSha1), "private/IsAlgorithmSupported/Decrypt"); } Assert.That(private_key.Decrypt(SecPadding.OAEP, cipher, out result), Is.EqualTo(SecStatusCode.Success), "Decrypt"); var expectEmpty = false; #if __MACOS__ if (!TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 12)) { expectEmpty = true; } #endif if (expectEmpty) { Assert.That(plain, Is.EqualTo(new byte [0]), "match (empty)"); } else { Assert.That(plain, Is.EqualTo(result), "match"); } private_key.Dispose(); } }
/// <summary> /// Override this method if you want the test to skip some specific types. /// By default types decorated with [Model] will be skipped. /// </summary> /// <param name="type">The Type to be tested</param> protected virtual bool Skip(Type type) { if (type.ContainsGenericParameters) { return(true); } #if !XAMCORE_2_0 // skip delegate (and other protocol references) foreach (object ca in type.GetCustomAttributes(false)) { if (ca is ProtocolAttribute) { return(true); } if (ca is ModelAttribute) { return(true); } } #endif switch (type.Name) { case "JSExport": // This is interesting: Apple defines a private JSExport class - if you try to define your own in an Objective-C project you get this warning at startup: // objc[334]: Class JSExport is implemented in both /Applications/Xcode91.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore (0x112c1e430) and /Users/rolf/Library/Developer/CoreSimulator/Devices/AC5323CF-225F-44D9-AA18-A37B7C28CA68/data/Containers/Bundle/Application/DEF9EAFC-CB5C-454F-97F5-669BBD00A609/jsexporttest.app/jsexporttest (0x105b49df0). One of the two will be used. Which one is undefined. // Due to how we treat models, we'll always look the Objective-C type up at runtime (even with the static registrar), // see that there's an existing JSExport type, and use that one instead of creating a new type. // This is problematic, because Apple's JSExport is completely unusable, and will crash if you try to do anything. return(true); #if !XAMCORE_2_0 case "AVAssetResourceLoader": // We have DisableDefaultCtor in XAMCORE_2_0 but can't change in compat because of backwards compat case "AVAssetResourceLoadingRequest": case "AVAssetResourceLoadingContentInformationRequest": #endif // on iOS 8.2 (beta 1) we get: NSInvalidArgumentException Caller did not provide an activityType, and this process does not have a NSUserActivityTypes in its Info.plist. // even if we specify an NSUserActivityTypes in the Info.plist - might be a bug or there's a new (undocumented) requirement case "NSUserActivity": return(true); case "NEPacketTunnelProvider": return(true); case "NSUnitDispersion": // -init should never be called on NSUnit! case "NSUnitVolume": // -init should never be called on NSUnit! case "NSUnitDuration": // -init should never be called on NSUnit! case "NSUnitElectricCharge": // -init should never be called on NSUnit! case "NSUnitElectricCurrent": // -init should never be called on NSUnit! case "NSUnitElectricPotentialDifference": // -init should never be called on NSUnit! case "NSUnitElectricResistance": // -init should never be called on NSUnit! case "NSUnit": // -init should never be called on NSUnit! case "NSUnitEnergy": // -init should never be called on NSUnit! case "NSUnitAcceleration": // -init should never be called on NSUnit! case "NSUnitFrequency": // -init should never be called on NSUnit! case "NSUnitAngle": // -init should never be called on NSUnit! case "NSUnitFuelEfficiency": // -init should never be called on NSUnit! case "NSUnitArea": // -init should never be called on NSUnit! case "NSUnitIlluminance": // -init should never be called on NSUnit! case "NSUnitConcentrationMass": // -init should never be called on NSUnit! case "NSUnitLength": // -init should never be called on NSUnit! case "NSUnitMass": // -init should never be called on NSUnit! case "NSUnitPower": // -init should never be called on NSUnit! case "NSUnitPressure": // -init should never be called on NSUnit! case "NSUnitSpeed": // -init should never be called on NSUnit! return(true); case "MPSCnnNeuron": // Cannot directly initialize MPSCNNNeuron. Use one of the sub-classes of MPSCNNNeuron case "MPSCnnNeuronPReLU": case "MPSCnnNeuronHardSigmoid": case "MPSCnnNeuronSoftPlus": return(true); case "MPSCnnBinaryConvolution": // [MPSCNNBinaryConvolution initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. case "MPSCnnDilatedPoolingMax": // [MPSCNNDilatedPoolingMax initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. case "MPSCnnPoolingL2Norm": // [MPSCNNPoolingL2Norm initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. return(true); case "MPSCnnBinaryFullyConnected": // Please initialize the MPSCNNBinaryFullyConnected class with initWithDevice:convolutionDescriptor:kernelWeights:biasTerms return(true); case "MPSCnnUpsampling": // Cannot directly initialize MPSCNNUpsampling. Use one of the sub-classes of MPSCNNUpsampling case "MPSCnnUpsamplingBilinear": case "MPSCnnUpsamplingNearest": return(true); case "MPSImageArithmetic": // Cannot directly initialize MPSImageArithmetic. Use one of the sub-classes of MPSImageArithmetic. return(true); case "QTMovie": return(TestRuntime.CheckSystemVersion(PlatformName.MacOSX, 10, 14, 4)); // Broke in macOS 10.14.4. } return(SkipDueToAttribute(type)); }
public void NSStringConstants() { Assert.NotNull(UTType.ExportedTypeDeclarationsKey, "ExportedTypeDeclarationsKey"); Assert.NotNull(UTType.ImportedTypeDeclarationsKey, "ImportedTypeDeclarationsKey"); Assert.NotNull(UTType.IdentifierKey, "IdentifierKey"); Assert.NotNull(UTType.TagSpecificationKey, "TagSpecificationKey"); Assert.NotNull(UTType.ConformsToKey, "ConformsToKey"); Assert.NotNull(UTType.DescriptionKey, "DescriptionKey"); Assert.NotNull(UTType.IconFileKey, "IconFileKey"); Assert.NotNull(UTType.ReferenceURLKey, "ReferenceURLKey"); Assert.NotNull(UTType.VersionKey, "VersionKey"); Assert.NotNull(UTType.TagClassFilenameExtension, "TagClassFilenameExtension"); Assert.NotNull(UTType.TagClassMIMEType, "TagClassMIMEType"); Assert.NotNull(UTType.Item, "Item"); Assert.NotNull(UTType.Content, "Content"); Assert.NotNull(UTType.CompositeContent, "CompositeContent"); Assert.NotNull(UTType.Application, "Application"); Assert.NotNull(UTType.Message, "Message"); Assert.NotNull(UTType.Contact, "Contact"); Assert.NotNull(UTType.Archive, "Archive"); Assert.NotNull(UTType.DiskImage, "DiskImage"); Assert.NotNull(UTType.Data, "Data"); Assert.NotNull(UTType.Directory, "Directory"); Assert.NotNull(UTType.Resolvable, "Resolvable"); Assert.NotNull(UTType.SymLink, "SymLink"); Assert.NotNull(UTType.MountPoint, "MountPoint"); Assert.NotNull(UTType.AliasFile, "AliasFile"); Assert.NotNull(UTType.AliasRecord, "AliasRecord"); Assert.NotNull(UTType.URL, "URL"); Assert.NotNull(UTType.FileURL, "FileURL"); Assert.NotNull(UTType.Text, "Text"); Assert.NotNull(UTType.PlainText, "PlainText"); Assert.NotNull(UTType.UTF8PlainText, "UTF8PlainText"); Assert.NotNull(UTType.UTF16ExternalPlainText, "UTF16ExternalPlainText"); Assert.NotNull(UTType.UTF16PlainText, "UTF16PlainText"); Assert.NotNull(UTType.RTF, "RTF"); Assert.NotNull(UTType.HTML, "HTML"); Assert.NotNull(UTType.XML, "XML"); Assert.NotNull(UTType.SourceCode, "SourceCode"); Assert.NotNull(UTType.CSource, "CSource"); Assert.NotNull(UTType.ObjectiveCSource, "ObjectiveCSource"); Assert.NotNull(UTType.CPlusPlusSource, "CPlusPlusSource"); Assert.NotNull(UTType.ObjectiveCPlusPlusSource, "ObjectiveCPlusPlusSource"); Assert.NotNull(UTType.CHeader, "CHeader"); Assert.NotNull(UTType.CPlusPlusHeader, "CPlusPlusHeader"); Assert.NotNull(UTType.JavaSource, "JavaSource"); Assert.NotNull(UTType.PDF, "PDF"); Assert.NotNull(UTType.RTFD, "RTFD"); Assert.NotNull(UTType.FlatRTFD, "FlatRTFD"); Assert.NotNull(UTType.TXNTextAndMultimediaData, "TXNTextAndMultimediaData"); Assert.NotNull(UTType.WebArchive, "WebArchive"); Assert.NotNull(UTType.Image, "Image"); Assert.NotNull(UTType.JPEG, "JPEG"); Assert.NotNull(UTType.JPEG2000, "JPEG2000"); Assert.NotNull(UTType.TIFF, "TIFF"); Assert.NotNull(UTType.GIF, "GIF"); Assert.NotNull(UTType.PNG, "PNG"); Assert.NotNull(UTType.QuickTimeImage, "QuickTimeImage"); Assert.NotNull(UTType.AppleICNS, "AppleICNS"); Assert.NotNull(UTType.BMP, "BMP"); Assert.NotNull(UTType.ICO, "ICO"); Assert.NotNull(UTType.AudiovisualContent, "AudiovisualContent"); Assert.NotNull(UTType.Movie, "Movie"); Assert.NotNull(UTType.Video, "Video"); Assert.NotNull(UTType.Audio, "Audio"); Assert.NotNull(UTType.QuickTimeMovie, "QuickTimeMovie"); Assert.NotNull(UTType.MPEG, "MPEG"); Assert.NotNull(UTType.MPEG4, "MPEG4"); Assert.NotNull(UTType.MP3, "MP3"); Assert.NotNull(UTType.MPEG4Audio, "MPEG4Audio"); Assert.NotNull(UTType.AppleProtectedMPEG4Audio, "AppleProtectedMPEG4Audio"); Assert.NotNull(UTType.Folder, "Folder"); Assert.NotNull(UTType.Volume, "Volume"); Assert.NotNull(UTType.Package, "Package"); Assert.NotNull(UTType.Bundle, "Bundle"); Assert.NotNull(UTType.Framework, "Framework"); Assert.NotNull(UTType.ApplicationBundle, "ApplicationBundle"); Assert.NotNull(UTType.ApplicationFile, "ApplicationFile"); Assert.NotNull(UTType.VCard, "VCard"); Assert.NotNull(UTType.InkText, "InkText"); if (TestRuntime.CheckXcodeVersion(7, 0)) { Assert.NotNull(UTType.SwiftSource, "SwiftSource"); } }
/// <summary> /// Override this method if you want the test to skip some specific types. /// By default types decorated with [Model] will be skipped. /// </summary> /// <param name="type">The Type to be tested</param> protected virtual bool Skip(Type type) { if (type.ContainsGenericParameters) { return(true); } switch (type.Name) { case "JSExport": // This is interesting: Apple defines a private JSExport class - if you try to define your own in an Objective-C project you get this warning at startup: // objc[334]: Class JSExport is implemented in both /Applications/Xcode91.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/JavaScriptCore.framework/JavaScriptCore (0x112c1e430) and /Users/rolf/Library/Developer/CoreSimulator/Devices/AC5323CF-225F-44D9-AA18-A37B7C28CA68/data/Containers/Bundle/Application/DEF9EAFC-CB5C-454F-97F5-669BBD00A609/jsexporttest.app/jsexporttest (0x105b49df0). One of the two will be used. Which one is undefined. // Due to how we treat models, we'll always look the Objective-C type up at runtime (even with the static registrar), // see that there's an existing JSExport type, and use that one instead of creating a new type. // This is problematic, because Apple's JSExport is completely unusable, and will crash if you try to do anything. return(true); // on iOS 8.2 (beta 1) we get: NSInvalidArgumentException Caller did not provide an activityType, and this process does not have a NSUserActivityTypes in its Info.plist. // even if we specify an NSUserActivityTypes in the Info.plist - might be a bug or there's a new (undocumented) requirement case "NSUserActivity": return(true); case "NEPacketTunnelProvider": return(true); // On iOS 14 (beta 4) we get: [NISimulator] To simulate Nearby Interaction distance and direction, launch two or more simulators and // move the simulator windows around the screen. // The same error occurs when trying to default init NISession in Xcode. // It seems that it is only possible to create a NISession when there are two devices or sims running, which makes sense given the description of // NISession from Apple API docs: "An object that identifies a unique connection between two peer devices" case "NISession": return(true); case "NSUnitDispersion": // -init should never be called on NSUnit! case "NSUnitVolume": // -init should never be called on NSUnit! case "NSUnitDuration": // -init should never be called on NSUnit! case "NSUnitElectricCharge": // -init should never be called on NSUnit! case "NSUnitElectricCurrent": // -init should never be called on NSUnit! case "NSUnitElectricPotentialDifference": // -init should never be called on NSUnit! case "NSUnitElectricResistance": // -init should never be called on NSUnit! case "NSUnit": // -init should never be called on NSUnit! case "NSUnitEnergy": // -init should never be called on NSUnit! case "NSUnitAcceleration": // -init should never be called on NSUnit! case "NSUnitFrequency": // -init should never be called on NSUnit! case "NSUnitAngle": // -init should never be called on NSUnit! case "NSUnitFuelEfficiency": // -init should never be called on NSUnit! case "NSUnitArea": // -init should never be called on NSUnit! case "NSUnitIlluminance": // -init should never be called on NSUnit! case "NSUnitConcentrationMass": // -init should never be called on NSUnit! case "NSUnitLength": // -init should never be called on NSUnit! case "NSUnitMass": // -init should never be called on NSUnit! case "NSUnitPower": // -init should never be called on NSUnit! case "NSUnitPressure": // -init should never be called on NSUnit! case "NSUnitSpeed": // -init should never be called on NSUnit! return(true); #if !NET // NSMenuView does not exist in .NET case "NSMenuView": return(TestRuntime.IsVM); // skip on vms due to hadware problems #endif // !NET case "MPSCnnNeuron": // Cannot directly initialize MPSCNNNeuron. Use one of the sub-classes of MPSCNNNeuron case "MPSCnnNeuronPReLU": case "MPSCnnNeuronHardSigmoid": case "MPSCnnNeuronSoftPlus": return(true); case "MPSCnnBinaryConvolution": // [MPSCNNBinaryConvolution initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. case "MPSCnnDilatedPoolingMax": // [MPSCNNDilatedPoolingMax initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. case "MPSCnnPoolingL2Norm": // [MPSCNNPoolingL2Norm initWithDevice:] is not allowed. Please use initializers that are not marked NS_UNAVAILABLE. return(true); case "MPSCnnBinaryFullyConnected": // Please initialize the MPSCNNBinaryFullyConnected class with initWithDevice:convolutionDescriptor:kernelWeights:biasTerms return(true); case "MPSCnnUpsampling": // Cannot directly initialize MPSCNNUpsampling. Use one of the sub-classes of MPSCNNUpsampling case "MPSCnnUpsamplingBilinear": case "MPSCnnUpsamplingNearest": return(true); case "MPSImageArithmetic": // Cannot directly initialize MPSImageArithmetic. Use one of the sub-classes of MPSImageArithmetic. return(true); case "CKDiscoverUserInfosOperation": // deprecated, throws exception case "CKSubscription": case "MPSCnnConvolutionState": return(true); case "AVSpeechSynthesisVoice": // Calling description crashes the test #if __WATCHOS__ return(TestRuntime.CheckXcodeVersion(12, 2)); // CheckExactXcodeVersion is not implemented in watchOS yet but will be covered by iOS parrot below #else return(TestRuntime.CheckExactXcodeVersion(12, 2, beta: 3)); #endif case "SKView": // Causes a crash later. Filed as radar://18440271. // Apple said they won't fix this ('init' isn't a designated initializer) return(true); } #if !NET switch (type.Namespace) { #if __IOS__ case "WatchKit": return(true); // WatchKit has been removed from iOS. #elif MONOMAC case "QTKit": return(true); // QTKit has been removed from macos. #endif } #endif // !NET // skip types that we renamed / rewrite since they won't behave correctly (by design) if (SkipDueToRejectedTypes(type)) { return(true); } return(SkipDueToAttribute(type)); }
public void Setup() { TestRuntime.AssertXcodeVersion(9, 0); // The API here was introduced to Mac Catalyst later than for the other frameworks, so we have this additional check TestRuntime.AssertSystemVersion(PlatformName.MacCatalyst, 14, 0, throwIfOtherPlatform: false); }
public void NotificationCenterVibrancyEffect_New() { TestRuntime.AssertSystemVersion(ApplePlatform.iOS, 8, 0, throwIfOtherPlatform: false); UIVibrancyEffect.CreateForNotificationCenter(); }
//[HostWorkflowAsWebService] public void ParallelWithinParallel() { Variable <int> counter = VariableHelper.CreateInitialized <int>("counter", 0); TestParallel parallel = new TestParallel("ParallelActivity") { Branches = { new TestParallelForEach <string>("Parallel For Each in Parallel") { Body = new TestSequence("Seq in Parallel For Each") { Activities = { new TestWhile("While Act") { Variables = { counter }, ConditionExpression = (env) => (bool)(counter.Get(env) < 3), Body = new TestSequence("Seq in While") { Activities = { new TestAssign <int>("Assign activity") { ToVariable = counter, ValueExpression = (env) => (int)counter.Get(env) + 1 }, new TestWriteLine("Writeline in While") { Message = "I am a message in while body" } } }, HintIterationCount = 3 } } }, HintValues = new List <string>() { "Hello", "How", "Are", "You" }, ValuesExpression = (context => new List <string>() { "Hello", "How", "Are", "You" }), }, new TestParallel("Parallel in Parallel") { Branches = { new TestWriteLine("Writeline", "Hello"), new TestWriteLine("Writeline2", "World") }, CompletionCondition = true, HintNumberOfBranchesExecution = 1, } }, HintNumberOfBranchesExecution = 2 }; ExpectedTrace trace = parallel.GetExpectedTrace(); TestRuntime.RunAndValidateWorkflow(parallel, trace); }
protected override bool CheckResponse(bool value, Type actualType, MethodBase method, ref string name) { if (value) { return(true); } var declaredType = method.DeclaringType; switch (declaredType.Name) { case "NSUrlSessionTaskMetrics": case "NSUrlSessionTaskTransactionMetrics": // does not respond but the properties works (see monotouch-test for a partial list) if (TestRuntime.CheckXcodeVersion(8, 0)) { return(true); } break; // broken with Xcode 12 beta 1 case "MidiCISession": switch (name) { case "deviceIdentification": if (TestRuntime.CheckXcodeVersion(12, 0)) { return(true); } break; } break; } switch (name) { // optional stuff defined in NSObject (but not implemented by every subclasses) case "encodeWithCoder:": case "objectDidEndEditing:": case "commitEditing": case "commitEditingWithDelegate:didCommitSelector:contextInfo:": if (declaredType.Name == "NSObject") { return(true); } break; // internal stuff that must be used case "_setCFClientFlags:callback:context:": case "_scheduleInCFRunLoop:forMode:": case "_unscheduleFromCFRunLoop:forMode:": // init* works (see monotouchtest.app) but does not respond when queried case "initWithFileAtPath:": case "initWithData:": case "initWithURL:": if (declaredType.Name == "NSInputStream") { return(true); } break; // init* works (see monotouchtest.app) but does not respond when queried case "initToMemory": case "initToFileAtPath:append:": if (declaredType.Name == "NSOutputStream") { return(true); } break; // init* works (see monotouchtest.app) but does not respond when queried case "initWithFileDescriptor:": case "initWithFileDescriptor:closeOnDealloc:": if (declaredType.Name == "NSFileHandle") { return(true); } break; case "initWithString:": case "initWithString:attributes:": case "initWithAttributedString:": if (declaredType.Name == "NSAttributedString" || declaredType.Name == "NSMutableAttributedString") { return(true); } break; } return(base.CheckResponse(value, actualType, method, ref name)); }
public void NoBranches() { TestParallel parallelActivity = new TestParallel("Parallel Activity"); TestRuntime.RunAndValidateWorkflow(parallelActivity); }
public void Init() => TestRuntime.AssertXcodeVersion(11, 0);
public void MultipleBranchesMultipleChildren() { TimeSpan time = new TimeSpan(0, 0, 2); DelegateInArgument <string> currentVariable = new DelegateInArgument <string>() { Name = "currentVariable" }; DelegateInArgument <string> currentVariable1 = new DelegateInArgument <string>() { Name = "currentVariable1" }; DelegateInArgument <string> currentVariable2 = new DelegateInArgument <string>() { Name = "currentVariable2" }; DelegateInArgument <string> currentVariable3 = new DelegateInArgument <string>() { Name = "currentVariable3" }; #region Sequence TestSequence sequence = new TestSequence() { Activities = { new TestWriteLine("WritelineAct1", "Hello"), new TestIf("If act1", HintThenOrElse.Then) { Condition = true, ThenActivity = new TestWriteLine("Writeline in then1") { Message = "I am writeline in if activity" } }, new TestDelay("Delay act1", time), new TestParallelForEach <string>("Parallel For Each In sequence") { HintValues = new List <string>() { "Element1", "Element2" }, ValuesExpression = (context => new List <string>() { "Element1", "Element2" }), CurrentVariable = currentVariable, Body = new TestWriteLine() { MessageExpression = (env) => (string)currentVariable.Get(env), HintMessageList = { "Element2", "Element1" } }, HintIterationCount = 2 }, new TestTryCatch() { Try = new TestThrow <NullReferenceException>() { ExpectedOutcome = Outcome.CaughtException() }, Catches = { new TestCatch <NullReferenceException>() } } } }; #endregion // Sequence #region Sequence1 TestSequence sequence1 = new TestSequence() { Activities = { new TestWriteLine("WritelineAct2", "Hello"), new TestIf("If act2", HintThenOrElse.Then) { Condition = true, ThenActivity = new TestWriteLine("Writeline in then","I am writeline in if activity") }, new TestDelay("Delay act2", time), new TestParallelForEach <string>("Parallel For Each In sequence1") { HintValues = new List <string>() { "Element1", "Element2" }, ValuesExpression = (context => new List <string>() { "Element1", "Element2" }), CurrentVariable = currentVariable1, Body = new TestWriteLine("Writeline in PFE") { MessageExpression = (env) => (string)currentVariable1.Get(env), HintMessageList = { "Element2", "Element1" } }, HintIterationCount = 2 }, new TestTryCatch() { Try = new TestThrow <NullReferenceException>() { ExpectedOutcome = Outcome.CaughtException() }, Catches = { new TestCatch <NullReferenceException>() } } } }; #endregion // Sequence1 #region Sequence2 TestSequence sequence2 = new TestSequence() { Activities = { new TestWriteLine("WritelineAct3", "Hello"), new TestIf("If act3", HintThenOrElse.Then) { Condition = true, ThenActivity = new TestWriteLine("Writeline in then","I am writeline in if activity") }, new TestDelay("Delay act3", time), new TestParallelForEach <string>("Parallel For Each In sequence2") { HintValues = new List <string>() { "Element1", "Element2" }, ValuesExpression = (context => new List <string>() { "Element1", "Element2" }), CurrentVariable = currentVariable2, Body = new TestWriteLine("Writeline in PFE") { MessageExpression = (env) => (string)currentVariable2.Get(env), HintMessageList = { "Element2", "Element1" } }, HintIterationCount = 2 }, new TestTryCatch() { Try = new TestThrow <NullReferenceException>() { ExpectedOutcome = Outcome.CaughtException() }, Catches = { new TestCatch <NullReferenceException>() } } } }; #endregion // Sequence2 #region Sequence3 TestSequence sequence3 = new TestSequence() { Activities = { new TestWriteLine("WritelineAct4", "Hello"), new TestIf("If act4", HintThenOrElse.Then) { Condition = true, ThenActivity = new TestWriteLine("Writeline in then","I am writeline in if activity") }, new TestDelay("Delay act4", time), new TestParallelForEach <string>("Parallel For Each In sequence3") { HintValues = new List <string>() { "Element1", "Element2" }, ValuesExpression = (context => new List <string>() { "Element1", "Element2" }), CurrentVariable = currentVariable3, Body = new TestWriteLine("Writeline in PFE") { MessageExpression = (env) => (string)currentVariable3.Get(env), HintMessageList = { "Element2", "Element1" } }, HintIterationCount = 2 }, new TestTryCatch() { Try = new TestThrow <NullReferenceException>() { ExpectedOutcome = Outcome.CaughtException() }, Catches = { new TestCatch <NullReferenceException>() } } } }; #endregion Sequence2 TestParallel parallelAct = new TestParallel("ParallelActivity") { Branches = { new TestSequence("First Sequence") { Activities ={ sequence } }, // Second sequence new TestSequence("Second sequence") { Activities ={ sequence1 } }, // Third sequence new TestSequence("Third sequence") { Activities ={ sequence2 } }, // Fourth Sequence new TestSequence("Fourth Sequence") { Activities ={ sequence3 } } }, HintNumberOfBranchesExecution = 4 }; ExpectedTrace trace = parallelAct.GetExpectedTrace(); TestRuntime.RunAndValidateWorkflow(parallelAct, trace); }
public void TestResumeBookmarkCallback() { const int noBranches = 10; Variable <int> value = VariableHelper.Create <int>("value"); TestParallel parallel = new TestParallel() { Variables = { value }, ExpectedOutcome = Outcome.Faulted }; for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); TestSequence sequence = new TestSequence() { Activities = { new TestWaitReadLine <int>(branchName, branchName) { BookmarkValue = value, WaitTime = TimeSpan.FromSeconds(10), } }, ExpectedOutcome = Outcome.Faulted, }; if (i > 0) { (sequence.Activities[0] as TestWaitReadLine <int>).ExpectedOutcome = Outcome.Faulted; } parallel.Branches.Add(sequence); } JsonFileInstanceStore.FileInstanceStore jsonStore = new JsonFileInstanceStore.FileInstanceStore(".\\~"); TestWorkflowRuntime runtime = TestRuntime.CreateTestWorkflowRuntime(parallel, null, jsonStore, PersistableIdleAction.Persist); runtime.ExecuteWorkflow(); runtime.WaitForIdle(); for (int i = 0; i < noBranches; i++) { string branchName = "Branch" + i.ToString(); runtime.BeginResumeBookMark(branchName, i, null, null); } runtime.WaitForTrace(new UserTrace(WaitReadLine <int> .BeforeWait)); runtime.AbortWorkflow("Aborting Workflow"); ExpectedTrace expectTrace = parallel.GetExpectedTrace(); expectTrace.Trace.Steps.Clear(); expectTrace.Trace.Steps.Add(new UserTrace(WaitReadLine <int> .BeforeWait)); expectTrace.Trace.Steps.Add(new UserTrace(WaitReadLine <int> .AfterWait)); expectTrace.AddVerifyTypes(typeof(UserTrace)); Exception exception; runtime.WaitForAborted(out exception, expectTrace); }
public void Ctors() { Matrix4 id = Matrix4.Identity; var V3 = new Vector3(1, 2, 3); using (var obj = new MDLTransform(id)) { Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation"); Asserts.AreEqual(Vector3.One, obj.Scale, "Scale"); Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation"); Asserts.AreEqual(id, obj.Matrix, "Matrix"); if (TestRuntime.CheckXcodeVersion(8, 0)) { Asserts.AreEqual(false, obj.ResetsTransform, "ResetsTransform"); } obj.Translation = V3; Asserts.AreEqual(V3, obj.Translation, "Translation 2"); } if (TestRuntime.CheckXcodeVersion(8, 0)) { using (var obj = new MDLTransform(id, true)) { Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation"); Asserts.AreEqual(Vector3.One, obj.Scale, "Scale"); Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation"); Asserts.AreEqual(id, obj.Matrix, "Matrix"); Asserts.AreEqual(true, obj.ResetsTransform, "ResetsTransform"); obj.Translation = V3; Asserts.AreEqual(V3, obj.Translation, "Translation 2"); } } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Scale = V3; Asserts.AreEqual(V3, obj.Scale, "Scale 2"); } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Rotation = V3; Asserts.AreEqual(V3, obj.Rotation, "Rotation 2"); } using (var obj = new MDLTransform(id)) { V3 *= 2; obj.Rotation = V3; Asserts.AreEqual(V3, obj.Rotation, "Rotation 2"); } var m4 = new Matrix4( 4, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 2, 3, 4, 1); using (var obj = new MDLTransform(m4)) { Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 3"); Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 3"); Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 3"); Asserts.AreEqual(m4, obj.Matrix, 0.0001f, "Matrix 3"); } var m4x4 = new MatrixFloat4x4( 4, 0, 0, 2, 0, 3, 0, 3, 0, 0, 2, 4, 0, 0, 0, 1); using (var obj = new MDLTransform(m4x4)) { Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 4"); Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 4"); Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 4"); Asserts.AreEqual(m4x4, obj.GetMatrix4x4(), 0.0001f, "Matrix4x4 4"); #if !TEST_BINDINGS_UNAVAILABLE Asserts.AreEqual(m4x4, CFunctions.GetMatrixFloat4x4(obj, "matrix"), 0.0001f, "Matrix4x4-native 4"); #endif } }
public void Setup() { TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 9, throwIfOtherPlatform: false); }
public void MinimumSdkCheck() { TestRuntime.AssertXcodeVersion(7, 0); }
public void SetUp() { TestRuntime.AssertXcodeVersion(6, 0); op = new CKModifySubscriptionsOperation(null, null); }
bool GetIsDirectBinding(NSObject obj) { int flags = TestRuntime.GetFlags(obj); return((flags & 4) == 4); }
public void ThrowInAction() { TestPick pick = new TestPick { DisplayName = "PickActivity", Branches = { new TestPickBranch { DisplayName = "Triggered", Trigger = new TestWriteLine("Trigger1") { Message = "Trigger1", }, Action = new TestThrow <ApplicationException>("ThrowInAction") { ExceptionExpression = (context => new ApplicationException("Fault in trigger")), ExpectedOutcome = Outcome.CaughtException(typeof(ApplicationException)), } }, new TestPickBranch { DisplayName = "NoTriggered", ExpectedOutcome = Outcome.Canceled, Trigger = new TestWriteLine("Trigger2") { Message = "Trigger2", ExpectedOutcome = Outcome.Completed, }, Action = new TestWriteLine("Action2") { Message = "Action2" } } } }; TestTryCatch testTCF = new TestTryCatch { DisplayName = "TryCatch", Try = pick, Catches = { new TestCatch <ApplicationException>() { Body = new TestWriteLine("CatchWriteLine") { Message = "Caught", } } } }; ExpectedTrace trace = testTCF.GetExpectedTrace(); TestRuntime.RunAndValidateWorkflow(testTCF, trace); }
public void SetUp() { TestRuntime.AssertXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch); descriptor = new MTLTileRenderPipelineDescriptor(); }