Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-122

Visual Studio Live Unit Testing doesn't work for creating an instance of a Realm

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      <!--- Questions: If you have questions about how to use Realm, please ask on -->
      <!--- StackOverflow: http://stackoverflow.com/questions/ask?tags=realm -->
      <!--- We monitor the realm tag. -->

      <!--- Feature Request: Just fill in the first two sections below. -->

      <!--- Bugs: To help you as fast as possible with an issue please describe your issue -->
      <!--- and the steps you have taken to reproduce it in as much detail as possible. -->

      <Unable to render embedded object: File (--- Thanks for helping us help you) not found. -->

      Goals

      <!--- What are you trying to achieve? -->
      I wanted to unit test my .NET Standard 2.0 library containing the latest Realm Nuget package with the Realm being initiated using a filename and some simple models to fill the database with using Visual Studio 2017's Live Testing feature on it's default settings.

      Expected Results

      <!--- What did you expect to happen? -->
      The same results as a manual unit test (using test explorer), that it just works to initiate the realm instance, also when using live unit testing.

      Actual Results

      <!--- What happened instead? -->
      <!--- e.g. the stack trace of a crash -->
      see this image for the problem

      manual testing works

      Steps to Reproduce

      <!--- What are steps we can follow to reproduce this issue? -->

      1. Create solution with two projects: one .NET Standard library project and one .NET Core 2.0 MSTEST project.
      2. In the library create a class that initiates the Realm instance (in the constructor).
      3. Create a few models within the library
      4. Write a test that has to create an object of the class that initiates the Realm instance.
      5. Turn on Live Testing
        6 ...
        7 Fail

      Code Sample

      <!--- Please provide a code sample or test case that highlights the issue. -->
      <!--- If relevant, include your model definitions. -->
      <!--- For larger code samples, links to external gists/repositories are preferred. -->
      <!--- Alternatively, you can share information confidentially via email at help@realm.io. -->
      <Unable to render embedded object: File (--- Full projects that we can compile and run ourselves are ideal) not found. -->

      Library project

      public class Database
      {
      private Realm _realm;
      public Database ()

      { _realm = Realm.GetInstance("fancyName"); }

      }

      public class FancyModel : RealmObject
      {
      [PrimaryKey]
      public int ID

      {get; set;}
      public string name {get; set;}

      }

      Test project

      public void DatabaseManagerInitiatesRealmObject()
      {
      PrivateObject databaseManager = new PrivateObject(oftype(DatabaseManager));
      Assert.IsNotNull(databseManager.GetField("_realm");
      }

      Version of Realm and Tooling

      All is done locally with te latest versions of the tooling

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: