Issue
Xamarin iOS native app. I have to write unit test for Realm api. It is the layer with ability to filter data. It can contain complicated Linq queries, so testing is necessary. For instance, method:
Task<List<T>> Get(int count, int type, int? id);
Creating NUnit test I need to get Realm object:
var realm = Realm.GetInstance(new InMemoryConfiguration("test"));
but getting an exception:
System.TypeInitializationException : The type initializer for 'Realms.SharedRealmHandle' threw an exception.
----> System.DllNotFoundException : realm-wrappers assembly:<unknown assembly> type:<unknown type> member:(null)
at Realms.InMemoryConfiguration.CreateRealm (Realms.Schema.RealmSchema schema) [0x0003e] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Configurations\InMemoryConfiguration.cs:62
at Realms.Realm.GetInstance (Realms.RealmConfigurationBase config, Realms.Schema.RealmSchema schema) [0x0003c] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Realm.cs:136
at Realms.Realm.GetInstance (Realms.RealmConfigurationBase config) [0x00000] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Realm.cs:81
at UnitTestREALM.TransactionsRealmApiTest.RealmApi () [0x00001] in /Users/user/Projects/myApp/UnitTestREALM/TransactionsRealmApiTest.cs:26
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
--DllNotFoundException
at (wrapper managed-to-native) Realms.SynchronizationContextEventLoopSignal.install_eventloop_callbacks(Realms.SynchronizationContextEventLoopSignal/get_eventloop,Realms.SynchronizationContextEventLoopSignal/post_on_event_loop,Realms.SynchronizationContextEventLoopSignal/release_eventloop)
at Realms.SynchronizationContextEventLoopSignal.Install () [0x0003b] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Native\SynchronizationContextEventLoopSignal.cs:122
at Realms.NativeCommon.Initialize () [0x00112] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Native\NativeCommon.cs:91
at Realms.SharedRealmHandle..cctor () [0x00000] in C:\jenkins\workspace\realm_realm-dotnet_PR\Realm\Realm\Handles\SharedRealmHandle.cs:128
So, main point that I can't create Realm instance.
Is launched iphone simulator necessary to work with Realm?
Are there some possibility to create unit tests for Realm?
Or should it be some kind of Auto tests?
Solution
As I found, solution is iOS Unit Test App (Solution -> Add -> New Project -> iOS -> Tests -> Unit Test App). There are few disadvantages, but it is possible to test Realm. The next challenge is to run it and get result with TeamCity.
Answered By - Alexdrob
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.