From 5ab74392ab2302f067efb79a2e727c161a4fbb79 Mon Sep 17 00:00:00 2001 From: Jordi Date: Tue, 12 Sep 2023 23:59:50 +0200 Subject: [PATCH] Add unit tests for new NewEntityRecord --- .github/workflows/CI-2x.yml | 6 ++--- .github/workflows/CI-PullRequest-2x.yml | 6 ++--- CHANGELOG.md | 1 + .../FakeContextTests/NewEntityRecordTests.cs | 26 +++++++++++++++++++ 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 tests/FakeXrmEasy.Core.Tests/FakeContextTests/NewEntityRecordTests.cs diff --git a/.github/workflows/CI-2x.yml b/.github/workflows/CI-2x.yml index 8bdc2377..bde26188 100644 --- a/.github/workflows/CI-2x.yml +++ b/.github/workflows/CI-2x.yml @@ -45,10 +45,10 @@ jobs: name: Sonar Quality Gate runs-on: windows-latest steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.11 + java-version: '17' - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/.github/workflows/CI-PullRequest-2x.yml b/.github/workflows/CI-PullRequest-2x.yml index c7d8cdf2..acc8b3ae 100644 --- a/.github/workflows/CI-PullRequest-2x.yml +++ b/.github/workflows/CI-PullRequest-2x.yml @@ -45,10 +45,10 @@ jobs: name: Sonar Quality Gate runs-on: windows-latest steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.11 + java-version: '17' - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis diff --git a/CHANGELOG.md b/CHANGELOG.md index b0c63bd7..f6c25c20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Changed +- Upgraded GitHub Actions to update Java major version to run SonarCloud analysis - https://github.com/DynamicsValue/fake-xrm-easy/issues/110 - Updated build scripts so that it actually deletes bin folders as opposed to doing dotnet clean - https://github.com/DynamicsValue/fake-xrm-easy/issues/76 - Introduced new NewEntityRecord method to easily create instances of entity records based on the current use of early-bound or late-bound entities - Resolves an issue with query evaluation and MultiOptionSets when using late bound entities or if type information is not present. - https://github.com/DynamicsValue/fake-xrm-easy/issues/66 diff --git a/tests/FakeXrmEasy.Core.Tests/FakeContextTests/NewEntityRecordTests.cs b/tests/FakeXrmEasy.Core.Tests/FakeContextTests/NewEntityRecordTests.cs new file mode 100644 index 00000000..989c1cbd --- /dev/null +++ b/tests/FakeXrmEasy.Core.Tests/FakeContextTests/NewEntityRecordTests.cs @@ -0,0 +1,26 @@ +using System; +using Crm; +using FakeXrmEasy.Tests; +using Xunit; + +namespace FakeXrmEasy.Core.Tests.FakeContextTests +{ + + public class NewEntityRecordTests: FakeXrmEasyTestsBase + { + [Fact] + public void Should_use_late_bound_if_no_early_bound_entity_has_been_used() + { + var contact = ((XrmFakedContext)_context).NewEntityRecord("contact"); + Assert.IsNotType(contact); + } + + [Fact] + public void Should_use_early_bound_if_the_context_is_using_early_bound() + { + _context.Initialize(new Contact() { Id = Guid.NewGuid()}); + var contact = ((XrmFakedContext)_context).NewEntityRecord("contact"); + Assert.IsType(contact); + } + } +} \ No newline at end of file