Skip to content

Commit

Permalink
Add unit tests for new NewEntityRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimontana82 committed Sep 12, 2023
1 parent 7d8452e commit 5ab7439
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI-2x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/CI-PullRequest-2x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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>(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>(contact);
}
}
}

0 comments on commit 5ab7439

Please sign in to comment.