You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a separate solution that houses our POCO's for use in our Xamarin.Forms mobile app. We have added Realm to one of the POCO's. The solution also has a Unit Test project. We have one unit test, that doesn't have anything to do with the POCO that we added Realm to, but we are getting a failure. This solution does not contain our droid and ios projects, so I'm not sure how to resolve.
Test method MyApp.Common.UnitTests.Utilities.UtilitiesTest.GetStateAbbreviationTest threw exception:
System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.PlatformNotSupportedException: The PCL build of Realm is being linked which probably means you need to use NuGet or otherwise link a platform-specific Realm.dll to your main application.
at Realms.Schema.RealmSchema.AddDefaultTypes(IEnumerable`1 types)
at RealmModuleInitializer.Initialize()
at .cctor()
--- End of inner exception stack trace ---
at MyApp.Common.UnitTests.Utilities.UtilitiesTest.GetStateAbbreviationTest()
We've tried adding Realm to the UnitTests project as well, but it didn't change and still failed the test. The test is below:
[TestClass]
public class UtilitiesTest
{
[TestMethod]
public void GetStateAbbreviationTest()
{
var abbreviation = new Common.Utilities.Utilities().GetStateAbbreviation("SOUTH CAROLINA");
Assert.AreEqual(abbreviation, "SC");
}
}
The method the test is executing looks like this (removing most states for brevity):
public string GetStateAbbreviation(string stateName)
{
Dictionary<string, string> stateList = new Dictionary<string, string>();
stateList.Add("ALABAMA", "AL");
stateList.Add("SOUTH CAROLINA", "SC");
stateList.Add("WYOMING", "WY");
if (!string.IsNullOrEmpty(stateName) && stateList.ContainsKey(stateName.ToUpper()))
return stateList[stateName.ToUpper()];
return null;
}
Why does this test fail with a Realm error if we aren't trying to test something for Realm? And is there any solution?
Realm Version: v1.4.0
The text was updated successfully, but these errors were encountered:
That's a bug on our part - our weaver creates a .cctor for your assembly to populate the initial schema which then invokes the PCL version of the method, which promptly throws. I'll try to get it fixed ASAP.
So, I just started using Realm and it doesn't look like you guys do pre-release builds that I could pull the update into my app? To get this fixed, am I supposed to compile your code?
We're still investigating how to best deliver our nightly builds and we haven't prioritized it yet. For now, letting us know which commit/PR you're interested in is the only way to get a pre-release :)
Here's the one related to your issue. Keep in mind that accessing things from Realm is still unsupported in PCL unit test, but at least it shouldn't prevent you from testing your other code.
We have a separate solution that houses our POCO's for use in our Xamarin.Forms mobile app. We have added Realm to one of the POCO's. The solution also has a Unit Test project. We have one unit test, that doesn't have anything to do with the POCO that we added Realm to, but we are getting a failure. This solution does not contain our droid and ios projects, so I'm not sure how to resolve.
We've tried adding Realm to the UnitTests project as well, but it didn't change and still failed the test. The test is below:
The method the test is executing looks like this (removing most states for brevity):
Why does this test fail with a Realm error if we aren't trying to test something for Realm? And is there any solution?
The text was updated successfully, but these errors were encountered: