diff --git a/.github/templates/main.yml b/.github/templates/main.yml index ad78ddf710..813727b990 100644 --- a/.github/templates/main.yml +++ b/.github/templates/main.yml @@ -4,6 +4,8 @@ #@ isRelease = "contains(github.head_ref, 'release')" +#@ ignoreSkippedJobsCondition = "always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')" + #@ secret_BaseUrl = "${{ (" + isRelease + " && secrets.REALM_QA_BASE_URL) || secrets.REALM_BASE_URL }}" #@ secret_AtlasBaseUrl = "${{ (" + isRelease + " && secrets.ATLAS_QA_BASE_URL) || secrets.ATLAS_BASE_URL }}" #@ secret_AtlasPublicKey = "${{ (" + isRelease + " && secrets.ATLAS_QA_PUBLIC_API_KEY) || secrets.ATLAS_PUBLIC_API_KEY }}" @@ -75,6 +77,7 @@ with: needs: - build-packages - #@ baasJobName + if: #@ ignoreSkippedJobsCondition env: CLUSTER_NAME: #@ "${{ needs.baas-" + name.replace(".", "").replace(" ", "-").lower() + ".outputs.clusterName }}" timeout-minutes: #@ testTimeout @@ -425,7 +428,12 @@ env: DOTNET_NOLOGO: true jobs: check-wrappers-cache: - runs-on: ubuntu-latest + strategy: + matrix: + os: + - ubuntu + - windows + runs-on: ${{ matrix.os }}-latest name: Check wrapper cache env: CACHE_SKIP_SAVE: true @@ -437,10 +445,13 @@ jobs: steps: - #@ template.replace(checkoutCode("recursive", False)) #@ for platform in getWrapperBinaryNames(): - - #@ checkCache("wrappers-" + platform, id = "check-cache-" + platform, name = "Check cache for " + platform) + #@ condition = "matrix.os == " + ("'windows'" if platform.find("windows") > -1 else "'ubuntu'") + - _: #@ template.replace(checkCache("wrappers-" + platform, id = "check-cache-" + platform, name = "Check cache for " + platform)) + if: #@ condition - _: #@ template.replace(uploadArtifacts("wrappers-" + platform, "wrappers/build/**", 1)) - if: #@ "steps.check-cache-" + platform + ".outputs.cache-hit == 'true'" + if: #@ condition + " && steps.check-cache-" + platform + ".outputs.cache-hit == 'true'" - run: git clean -fdx + if: #@ condition #@ end build-wrappers-macos: runs-on: macos-latest @@ -541,10 +552,7 @@ jobs: - build-wrappers-android - build-wrappers-linux - build-wrappers-windows-uwp - if: | - always() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') + if: #@ ignoreSkippedJobsCondition outputs: package_version: ${{ steps.get-version.outputs.version }} timeout-minutes: #@ wrappersTimeout @@ -581,7 +589,7 @@ jobs: name: Publish package to S3 needs: - build-packages - if: ${{ github.event_name != 'pull_request' }} + if: #@ ignoreSkippedJobsCondition + " && github.event_name != 'pull_request'" steps: - #@ template.replace(checkoutCode(False, False)) - #@ template.replace(fetchPackageArtifacts()) @@ -593,6 +601,7 @@ jobs: name: "Test .NET" needs: - build-packages + if: #@ ignoreSkippedJobsCondition strategy: fail-fast: false matrix: @@ -650,7 +659,7 @@ jobs: name: Benchmark Linux needs: build-packages runs-on: performance-tests - if: ${{ github.event_name == 'push' }} + if: #@ ignoreSkippedJobsCondition + " && github.event_name != 'pull_request'" timeout-minutes: #@ testTimeout steps: - #@ template.replace(cleanupWorkspace()) @@ -671,4 +680,3 @@ jobs: dashboard-path: dashboard.charts nuget-package: ${{ github.workspace }}/Realm/packages/Realm.${{ needs.build-packages.outputs.package_version }}.nupkg - #@ uploadArtifacts("dashboard.charts", "dashboard.charts", 30) - diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f5f24af579..f5f9f359c8 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,12 @@ env: DOTNET_NOLOGO: true jobs: check-wrappers-cache: - runs-on: ubuntu-latest + strategy: + matrix: + os: + - ubuntu + - windows + runs-on: ${{ matrix.os }}-latest name: Check wrapper cache env: CACHE_SKIP_SAVE: true @@ -39,168 +44,192 @@ jobs: with: path: ./wrappers/build/** key: wrappers-macos-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-macos uses: actions/upload-artifact@v2 with: name: wrappers-macos path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-macos.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-macos.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for ios id: check-cache-ios uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-ios-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-ios uses: actions/upload-artifact@v2 with: name: wrappers-ios path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-ios.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-ios.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for linux id: check-cache-linux uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-linux-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-linux uses: actions/upload-artifact@v2 with: name: wrappers-linux path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-linux.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-linux.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for android-armeabi-v7a id: check-cache-android-armeabi-v7a uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-android-armeabi-v7a-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-armeabi-v7a uses: actions/upload-artifact@v2 with: name: wrappers-android-armeabi-v7a path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-android-armeabi-v7a.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for android-arm64-v8a id: check-cache-android-arm64-v8a uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-android-arm64-v8a-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-arm64-v8a uses: actions/upload-artifact@v2 with: name: wrappers-android-arm64-v8a path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-android-arm64-v8a.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for android-x86 id: check-cache-android-x86 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-android-x86-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-x86 uses: actions/upload-artifact@v2 with: name: wrappers-android-x86 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-android-x86.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for android-x86_64 id: check-cache-android-x86_64 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-android-x86_64-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'ubuntu' - name: Store artifacts for wrappers-android-x86_64 uses: actions/upload-artifact@v2 with: name: wrappers-android-x86_64 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-android-x86_64.outputs.cache-hit == 'true' + if: matrix.os == 'ubuntu' && steps.check-cache-android-x86_64.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'ubuntu' - name: Check cache for windows-Win32 id: check-cache-windows-Win32 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-windows-Win32-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-Win32 uses: actions/upload-artifact@v2 with: name: wrappers-windows-Win32 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-windows-Win32.outputs.cache-hit == 'true' + if: matrix.os == 'windows' && steps.check-cache-windows-Win32.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'windows' - name: Check cache for windows-x64 id: check-cache-windows-x64 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-windows-x64-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-x64 uses: actions/upload-artifact@v2 with: name: wrappers-windows-x64 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-windows-x64.outputs.cache-hit == 'true' + if: matrix.os == 'windows' && steps.check-cache-windows-x64.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'windows' - name: Check cache for windows-uwp-Win32 id: check-cache-windows-uwp-Win32 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-windows-uwp-Win32-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-Win32 uses: actions/upload-artifact@v2 with: name: wrappers-windows-uwp-Win32 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-Win32.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'windows' - name: Check cache for windows-uwp-x64 id: check-cache-windows-uwp-x64 uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-windows-uwp-x64-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-x64 uses: actions/upload-artifact@v2 with: name: wrappers-windows-uwp-x64 path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-x64.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'windows' - name: Check cache for windows-uwp-ARM id: check-cache-windows-uwp-ARM uses: nirinchev/cache@d7c96a77c26ab70dd32b202c885cb4b34d95d8a8 with: path: ./wrappers/build/** key: wrappers-windows-uwp-ARM-Release-${{hashFiles('./wrappers/**')}} + if: matrix.os == 'windows' - name: Store artifacts for wrappers-windows-uwp-ARM uses: actions/upload-artifact@v2 with: name: wrappers-windows-uwp-ARM path: ${{ github.workspace }}/wrappers/build/** retention-days: 1 - if: steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' + if: matrix.os == 'windows' && steps.check-cache-windows-uwp-ARM.outputs.cache-hit == 'true' - run: git clean -fdx + if: matrix.os == 'windows' build-wrappers-macos: runs-on: macos-latest name: Wrappers macOS @@ -500,10 +529,7 @@ jobs: - build-wrappers-android - build-wrappers-linux - build-wrappers-windows-uwp - if: | - always() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') outputs: package_version: ${{ steps.get-version.outputs.version }} timeout-minutes: 90 @@ -666,7 +692,7 @@ jobs: name: Publish package to S3 needs: - build-packages - if: ${{ github.event_name != 'pull_request' }} + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' steps: - name: Checkout code uses: actions/checkout@v2 @@ -727,6 +753,7 @@ jobs: needs: - build-packages - baas-net-framework + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-net-framework.outputs.clusterName }} timeout-minutes: 45 @@ -815,6 +842,7 @@ jobs: needs: - build-packages - baas-uwp-managed + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-uwp-managed.outputs.clusterName }} timeout-minutes: 45 @@ -889,6 +917,7 @@ jobs: name: Test .NET needs: - build-packages + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') strategy: fail-fast: false matrix: @@ -975,6 +1004,7 @@ jobs: needs: - build-packages - baas-xamarinmacos + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-xamarinmacos.outputs.clusterName }} timeout-minutes: 45 @@ -1061,6 +1091,7 @@ jobs: needs: - build-packages - baas-xamarinios + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-xamarinios.outputs.clusterName }} timeout-minutes: 45 @@ -1152,6 +1183,7 @@ jobs: needs: - build-packages - baas-xamarinandroid + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-xamarinandroid.outputs.clusterName }} timeout-minutes: 45 @@ -1312,6 +1344,7 @@ jobs: needs: - build-packages - baas-code-coverage + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') env: CLUSTER_NAME: ${{ needs.baas-code-coverage.outputs.clusterName }} timeout-minutes: 45 @@ -1509,7 +1542,7 @@ jobs: name: Benchmark Linux needs: build-packages runs-on: performance-tests - if: ${{ github.event_name == 'push' }} + if: always() && !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' timeout-minutes: 45 steps: - name: Cleanup Workspace diff --git a/Tests/Realm.Tests/Database/MigrationTests.cs b/Tests/Realm.Tests/Database/MigrationTests.cs index 15f3ba4410..9e529f0350 100644 --- a/Tests/Realm.Tests/Database/MigrationTests.cs +++ b/Tests/Realm.Tests/Database/MigrationTests.cs @@ -60,11 +60,9 @@ public void TriggerMigrationBySchemaEditing() // Because Realms opened during migration are not immediately disposed of, they can't be deleted. // To circumvent that, we're leaking realm files. // See https://github.com/realm/realm-dotnet/issues/1357 - var path = TestHelpers.CopyBundledFileToDocuments(FileToMigrate, Path.Combine(InteropConfig.DefaultStorageFolder, Guid.NewGuid().ToString())); - var triggersSchemaFieldValue = string.Empty; - var configuration = new RealmConfiguration(path) + var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -94,6 +92,8 @@ public void TriggerMigrationBySchemaEditing() } }; + TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); + var realm = GetRealm(configuration); var person = realm.All().Single(); Assert.That(person.LastName, Is.EqualTo(triggersSchemaFieldValue)); @@ -105,11 +105,9 @@ public void ExceptionInMigrationCallback() // Because Realms opened during migration are not immediately disposed of, they can't be deleted. // To circumvent that, we're leaking realm files. // See https://github.com/realm/realm-dotnet/issues/1357 - var path = TestHelpers.CopyBundledFileToDocuments(FileToMigrate, Path.Combine(InteropConfig.DefaultStorageFolder, Guid.NewGuid().ToString())); - var dummyException = new Exception(); - var configuration = new RealmConfiguration(path) + var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -118,6 +116,8 @@ public void ExceptionInMigrationCallback() } }; + TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); + var ex = Assert.Throws(() => GetRealm(configuration)); Assert.That(ex.Flatten().InnerException, Is.SameAs(dummyException)); } @@ -176,9 +176,7 @@ public void MigrationTriggersDelete() [Test] public void MigrationRenameProperty() { - var path = TestHelpers.CopyBundledFileToDocuments(FileToMigrate, Path.Combine(InteropConfig.DefaultStorageFolder, Guid.NewGuid().ToString())); - - var configuration = new RealmConfiguration(path) + var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -200,17 +198,17 @@ public void MigrationRenameProperty() } }; + TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); + using var realm = GetRealm(configuration); } [Test] public void MigrationRenamePropertyErrors() { - var path = TestHelpers.CopyBundledFileToDocuments(FileToMigrate, Path.Combine(InteropConfig.DefaultStorageFolder, Guid.NewGuid().ToString())); - var oldPropertyValues = new List(); - var configuration = new RealmConfiguration(path) + var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -219,10 +217,12 @@ public void MigrationRenamePropertyErrors() } }; + TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); + var ex = Assert.Throws(() => GetRealm(configuration)); Assert.That(ex.Message, Does.Contain("Renamed property 'Person.PropertyNotInNewSchema' does not exist")); - configuration = new RealmConfiguration(path) + configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -234,7 +234,7 @@ public void MigrationRenamePropertyErrors() var ex2 = Assert.Throws(() => GetRealm(configuration)); Assert.That(ex2.Flatten().InnerException.Message, Does.Contain("Cannot rename property 'Person.PropertyNotInOldSchema' because it does not exist")); - configuration = new RealmConfiguration(path) + configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -246,7 +246,7 @@ public void MigrationRenamePropertyErrors() ex2 = Assert.Throws(() => GetRealm(configuration)); Assert.That(ex2.Flatten().InnerException.Message, Does.Contain("Cannot rename properties for type 'NonExistingType' because it does not exist")); - configuration = new RealmConfiguration(path) + configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -258,7 +258,7 @@ public void MigrationRenamePropertyErrors() ex2 = Assert.Throws(() => GetRealm(configuration)); Assert.That(ex2.Flatten().InnerException.Message, Does.Contain("Cannot rename property 'Person.TriggersSchema' to 'Birthday' because it would change from type 'string' to 'date'.")); - configuration = new RealmConfiguration(path) + configuration = new RealmConfiguration(configuration.DatabasePath) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -274,9 +274,7 @@ public void MigrationRenamePropertyErrors() [Test] public void MigrationRenamePropertyInvalidArguments() { - var path = TestHelpers.CopyBundledFileToDocuments(FileToMigrate, Path.Combine(InteropConfig.DefaultStorageFolder, Guid.NewGuid().ToString())); - - var configuration = new RealmConfiguration(path) + var configuration = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 100, MigrationCallback = (migration, oldSchemaVersion) => @@ -291,13 +289,15 @@ public void MigrationRenamePropertyInvalidArguments() } }; + TestHelpers.CopyBundledFileToDocuments(FileToMigrate, configuration.DatabasePath); + using var realm = GetRealm(configuration); } [Test] public void MigrationRemoveTypeInSchema() { - var oldRealmConfig = new RealmConfiguration() + var oldRealmConfig = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 0, Schema = new[] { typeof(Dog), typeof(Owner), typeof(Person) }, @@ -307,7 +307,7 @@ public void MigrationRemoveTypeInSchema() { } - var newRealmConfig = new RealmConfiguration() + var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, Schema = new[] { typeof(PrimaryKeyObjectIdObject), typeof(Person) }, @@ -324,7 +324,7 @@ public void MigrationRemoveTypeInSchema() [Test] public void MigrationRemoveTypeNotInSchema() { - var oldRealmConfig = new RealmConfiguration() + var oldRealmConfig = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 0, Schema = new[] { typeof(Dog), typeof(Owner), typeof(Person) }, @@ -339,7 +339,7 @@ public void MigrationRemoveTypeNotInSchema() } var migrationCallbackCalled = false; - var newRealmConfig = new RealmConfiguration() + var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, Schema = new[] { typeof(Dog), typeof(Owner) }, @@ -370,7 +370,7 @@ public void MigrationRemoveTypeNotInSchema() Assert.That(newRealm.Schema.TryFindObjectSchema("Person", out _), Is.False); } - var newRealmDynamicConfig = new RealmConfiguration() + var newRealmDynamicConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, IsDynamic = true, @@ -385,7 +385,7 @@ public void MigrationRemoveTypeNotInSchema() [Test] public void MigrationRemoveTypeInvalidArguments() { - var oldRealmConfig = new RealmConfiguration() + var oldRealmConfig = new RealmConfiguration(Guid.NewGuid().ToString()) { SchemaVersion = 0, Schema = new[] { typeof(Dog), typeof(Owner), typeof(Person) }, @@ -395,7 +395,7 @@ public void MigrationRemoveTypeInvalidArguments() { } - var newRealmConfig = new RealmConfiguration() + var newRealmConfig = new RealmConfiguration(oldRealmConfig.DatabasePath) { SchemaVersion = 1, Schema = new[] { typeof(PrimaryKeyObjectIdObject), typeof(Person) }, diff --git a/Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt b/Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt index 08e046ab83..27735b15ac 100644 --- a/Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt +++ b/Tests/Realm.Tests/EmbeddedResources/nunit3-junit.xslt @@ -30,7 +30,7 @@ - + @@ -58,12 +58,11 @@ - + - - + \ No newline at end of file diff --git a/Tests/Realm.Tests/RealmTest.cs b/Tests/Realm.Tests/RealmTest.cs index 1a6796013c..aa2b241201 100644 --- a/Tests/Realm.Tests/RealmTest.cs +++ b/Tests/Realm.Tests/RealmTest.cs @@ -42,7 +42,7 @@ static RealmTest() if (!TestHelpers.IsUnity) { #pragma warning disable CA1837 // Use Environment.ProcessId instead of Process.GetCurrentProcess().Id - InteropConfig.DefaultStorageFolder = Path.Combine(Path.GetTempPath(), $"rt-${System.Diagnostics.Process.GetCurrentProcess().Id}"); + InteropConfig.DefaultStorageFolder = Path.Combine(Path.GetTempPath(), $"rt-{System.Diagnostics.Process.GetCurrentProcess().Id}"); #pragma warning restore CA1837 // Use Environment.ProcessId instead of Process.GetCurrentProcess().Id Directory.CreateDirectory(InteropConfig.DefaultStorageFolder); } diff --git a/Tests/Realm.Tests/TestHelpers.cs b/Tests/Realm.Tests/TestHelpers.cs index 7fff25edac..df673a460b 100644 --- a/Tests/Realm.Tests/TestHelpers.cs +++ b/Tests/Realm.Tests/TestHelpers.cs @@ -360,7 +360,7 @@ public static async Task AssertThrows(Func function) public static void TransformTestResults(string resultPath) { - var transformFile = CopyBundledFileToDocuments("nunit3-junit.xslt", "nunit3-junit.xslt"); + var transformFile = CopyBundledFileToDocuments("nunit3-junit.xslt", $"{Guid.NewGuid()}.xslt"); TransformHelpers.TransformTestResults(resultPath, transformFile); } diff --git a/Tests/Realm.Tests/TransformHelpers.cs b/Tests/Realm.Tests/TransformHelpers.cs index 4a36165ebc..235655d619 100644 --- a/Tests/Realm.Tests/TransformHelpers.cs +++ b/Tests/Realm.Tests/TransformHelpers.cs @@ -54,7 +54,7 @@ public static void ExtractBundledFile(string filename, string destPath) } using var stream = assembly.GetManifestResourceStream(resourceName); - using var destination = new FileStream(destPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); + using var destination = new FileStream(destPath, FileMode.Create, FileAccess.ReadWrite, FileShare.None); stream.CopyTo(destination); } }