diff --git a/.github/workflows/CI-PullRequest-2x.yml b/.github/workflows/CI-PullRequest-2x.yml index f16d36fe..ec282152 100644 --- a/.github/workflows/CI-PullRequest-2x.yml +++ b/.github/workflows/CI-PullRequest-2x.yml @@ -36,7 +36,7 @@ jobs: run: dotnet nuget enable source github - name: Build - run: pwsh ./build.ps1 -configuration ${{matrix.configuration}} -targetFramework 'all' + run: pwsh ./build.ps1 -configuration ${{matrix.configuration}} -targetFrameworks 'all' env: NUGET_USERNAME: ${{github.repository_owner}} NUGET_TOKEN: ${{ secrets.PACKAGES_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index cccb07fd..9350c529 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changed +- **BREAKING CHANGE**: This will **only** affect you if you use XrmRealContext class. Moved XrmRealContext to a separate FakeXrmEasy.Integration package to remove dependency on XrmTooling - https://github.com/DynamicsValue/fake-xrm-easy/issues/160 - Resolves an issue in FetchXml queries when using arithmetic values and no early bound assemblies are used. It will now read from injected metadata in absence of proxy type assemblies - https://github.com/DynamicsValue/fake-xrm-easy/issues/158 - Resolves issue in MetadataGenerator where relationship properties were generated in the wrong order, also generates ManyToMany relationship properties - https://github.com/DynamicsValue/fake-xrm-easy/issues/135 - Adds implementation of RelatedEntities in Update message , before it was implemented only for Create - https://github.com/DynamicsValue/fake-xrm-easy/issues/154 diff --git a/FakeXrmEasy.Core.sln b/FakeXrmEasy.Core.sln index 4b92b33a..3e132287 100644 --- a/FakeXrmEasy.Core.sln +++ b/FakeXrmEasy.Core.sln @@ -21,9 +21,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataverseEntities", "tests\ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - FAKE_XRM_EASY_9|Any CPU = FAKE_XRM_EASY_9|Any CPU - FAKE_XRM_EASY_9|x64 = FAKE_XRM_EASY_9|x64 - FAKE_XRM_EASY_9|x86 = FAKE_XRM_EASY_9|x86 + FAKE_XRM_EASY_9|Any CPU = FAKE_XRM_EASY_9|Any CPU + FAKE_XRM_EASY_9|x64 = FAKE_XRM_EASY_9|x64 + FAKE_XRM_EASY_9|x86 = FAKE_XRM_EASY_9|x86 FAKE_XRM_EASY_2013|Any CPU = FAKE_XRM_EASY_2013|Any CPU FAKE_XRM_EASY_2013|x64 = FAKE_XRM_EASY_2013|x64 FAKE_XRM_EASY_2013|x86 = FAKE_XRM_EASY_2013|x86 @@ -46,7 +46,7 @@ Global {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_9|x64.ActiveCfg = FAKE_XRM_EASY_9|Any CPU {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_9|x64.Build.0 = FAKE_XRM_EASY_9|Any CPU {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_9|x86.ActiveCfg = FAKE_XRM_EASY_9|Any CPU - {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_9|x86.Build.0 = FAKE_XRM_EASY_9|Any CPU + {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_9|x86.Build.0 = FAKE_XRM_EASY_9|Any CPU {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|Any CPU.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|Any CPU.Build.0 = FAKE_XRM_EASY_2013|Any CPU {CE7EE93C-E98A-4AE7-AE84-B4FA7CEB49FE}.FAKE_XRM_EASY_2013|x64.ActiveCfg = FAKE_XRM_EASY_2013|Any CPU diff --git a/pack-configuration.ps1 b/pack-configuration.ps1 index b00c437d..564b8a81 100644 --- a/pack-configuration.ps1 +++ b/pack-configuration.ps1 @@ -48,20 +48,20 @@ if($targetFrameworks -eq "all") { if($versionSuffix -eq "") { - dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -o $tempNupkgFolder $projectPath/$projectName.csproj + dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:IsPacking="true" -o $tempNupkgFolder $projectPath/$projectName.csproj } else { - dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -o $tempNupkgFolder $projectPath/$projectName.csproj --version-suffix $versionSuffix + dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:IsPacking="true" -o $tempNupkgFolder $projectPath/$projectName.csproj --version-suffix $versionSuffix } } else { if($versionSuffix -eq "") { - dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:TargetFrameworks=$targetFrameworks -o $tempNupkgFolder $projectPath/$projectName.csproj + dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:IsPacking="true" -p:TargetFrameworks=$targetFrameworks -o $tempNupkgFolder $projectPath/$projectName.csproj } else { - dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:TargetFrameworks=$targetFrameworks -o $tempNupkgFolder $projectPath/$projectName.csproj --version-suffix $versionSuffix + dotnet pack --no-build --configuration $configuration -p:PackageID=$packageId -p:Title=$packageId -p:PackTests=$packTests -p:IsPacking="true" -p:TargetFrameworks=$targetFrameworks -o $tempNupkgFolder $projectPath/$projectName.csproj --version-suffix $versionSuffix } } diff --git a/pack-src-project.ps1 b/pack-src-project.ps1 new file mode 100644 index 00000000..7b2fdc51 --- /dev/null +++ b/pack-src-project.ps1 @@ -0,0 +1,29 @@ +param ( + [string]$versionSuffix = "", + [string]$targetFrameworks = "netcoreapp3.1", + [string]$packageIdPrefix = "", + [string]$projectName = "", + [string]$projectPath = "" + ) + +Write-Host "Running with versionSuffix '$($versionSuffix)'..." + +$tempNupkgFolder = './nupkgs' + +Write-Host "Packing All Configurations for project $($projectName)" -ForegroundColor Green + + if($targetFrameworks -eq "netcoreapp3.1") + { + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_365" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_9" + } + else { + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2013" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2015" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2016" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_365" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_9" + } + +Write-Host "Pack Succeeded :)" -ForegroundColor Green \ No newline at end of file diff --git a/pack-src.ps1 b/pack-src.ps1 index 82767562..9a880293 100644 --- a/pack-src.ps1 +++ b/pack-src.ps1 @@ -13,18 +13,6 @@ $projectPath = "src/FakeXrmEasy.Core" Write-Host "Packing All Configurations for project $($projectName)" -ForegroundColor Green - if($targetFrameworks -eq "netcoreapp3.1") - { - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_365" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_9" - } - else { - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2013" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2015" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_2016" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_365" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -configuration "FAKE_XRM_EASY_9" - } +./pack-src-project.ps1 -targetFrameworks $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix Write-Host "Pack Succeeded :)" -ForegroundColor Green \ No newline at end of file diff --git a/pack-tests-project.ps1 b/pack-tests-project.ps1 new file mode 100644 index 00000000..adc08494 --- /dev/null +++ b/pack-tests-project.ps1 @@ -0,0 +1,29 @@ +param ( + [string]$versionSuffix = "", + [string]$targetFrameworks = "netcoreapp3.1", + [string]$packageIdPrefix = "", + [string]$projectName = "", + [string]$projectPath = "" + ) + +Write-Host "Running with versionSuffix '$($versionSuffix)'..." + +$tempNupkgFolder = './nupkgs' + +Write-Host "Packing All Configurations for project $($projectName)" -ForegroundColor Green + + if($targetFrameworks -eq "netcoreapp3.1") + { + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_365" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_9" + } + else { + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2013" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2015" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2016" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_365" + ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_9" + } + +Write-Host "Pack Succeeded :)" -ForegroundColor Green \ No newline at end of file diff --git a/pack-tests.ps1 b/pack-tests.ps1 index fdc9c768..e310569d 100644 --- a/pack-tests.ps1 +++ b/pack-tests.ps1 @@ -13,18 +13,6 @@ $projectPath = "tests/FakeXrmEasy.Core.Tests" Write-Host "Packing All Configurations for project $($projectName)" -ForegroundColor Green - if($targetFrameworks -eq "netcoreapp3.1") - { - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_365" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_9" - } - else { - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2013" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2015" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_2016" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_365" - ./pack-configuration.ps1 -targetFramework $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix -packTests "true" -configuration "FAKE_XRM_EASY_9" - } +./pack-tests-project.ps1 -targetFrameworks $targetFrameworks -projectName $projectName -projectPath $projectPath -packageIdPrefix $packageIdPrefix -versionSuffix $versionSuffix Write-Host "Pack Succeeded :)" -ForegroundColor Green \ No newline at end of file diff --git a/push.ps1 b/push.ps1 index de65ee64..37778829 100644 --- a/push.ps1 +++ b/push.ps1 @@ -1,6 +1,6 @@ param ( [string]$packageSource = "local-packages", - [string]$packagePrefix = "FakeXrmEasy.Abstractions" + [string]$packagePrefix = "FakeXrmEasy.Core" ) Write-Host "Running with packageSource '$($packageSource)'..." diff --git a/src/FakeXrmEasy.Core/FakeXrmEasy.Core.csproj b/src/FakeXrmEasy.Core/FakeXrmEasy.Core.csproj index ec4daaa8..28ae8631 100644 --- a/src/FakeXrmEasy.Core/FakeXrmEasy.Core.csproj +++ b/src/FakeXrmEasy.Core/FakeXrmEasy.Core.csproj @@ -58,28 +58,23 @@ - - - - - diff --git a/src/FakeXrmEasy.Core/FileStorage/FileStorageSettings.cs b/src/FakeXrmEasy.Core/FileStorage/FileStorageSettings.cs index 66a13425..3f0bde3e 100644 --- a/src/FakeXrmEasy.Core/FileStorage/FileStorageSettings.cs +++ b/src/FakeXrmEasy.Core/FileStorage/FileStorageSettings.cs @@ -1,5 +1,8 @@ namespace FakeXrmEasy.Core.FileStorage { + /// + /// Sets default file and image storage settings + /// public interface IFileStorageSettings { /// @@ -12,6 +15,10 @@ public interface IFileStorageSettings /// int ImageMaxSizeInKB { get; set; } } + + /// + /// Sets default file and image storage settings + /// public class FileStorageSettings: IFileStorageSettings { diff --git a/src/FakeXrmEasy.Core/XrmRealContext.cs b/src/FakeXrmEasy.Core/XrmRealContext.cs deleted file mode 100644 index 69f06ad5..00000000 --- a/src/FakeXrmEasy.Core/XrmRealContext.cs +++ /dev/null @@ -1,206 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.Xrm.Sdk; -using System.Configuration; -using System.IO; - -using System.Xml.Linq; -using System.Linq; - -using System.IO.Compression; -using System.Runtime.Serialization; - -using FakeXrmEasy.Abstractions; -using FakeXrmEasy.Abstractions.Plugins; -using FakeXrmEasy.Abstractions.Enums; -using FakeXrmEasy.Abstractions.Exceptions; - -#if FAKE_XRM_EASY_NETCORE -using Microsoft.Powerplatform.Cds.Client; -#elif FAKE_XRM_EASY_2016 || FAKE_XRM_EASY_365 || FAKE_XRM_EASY_9 -using Microsoft.Xrm.Tooling.Connector; -#else -using Microsoft.Xrm.Client; -using Microsoft.Xrm.Client.Services; -#endif - -namespace FakeXrmEasy -{ - /// - /// Reuse unit test syntax to test against a real CRM organisation - /// It uses a real CRM organisation service instance - /// - public class XrmRealContext : IXrmRealContext - { - /// - /// - /// - public FakeXrmEasyLicense? LicenseContext { get; set; } - - /// - /// - /// - public string ConnectionStringName { get; set; } = "fakexrmeasy-connection"; - - /// - /// Use these user to impersonate calls - /// - public ICallerProperties CallerProperties { get; set; } - - /// - /// Plugin Context Properties - /// - public IXrmFakedPluginContextProperties PluginContextProperties { get; set; } - - /// - /// Internal reference to an IOrganizationService. - /// - protected IOrganizationService _service; - - /// - /// A fake tracing service if one is needed - /// - private IXrmFakedTracingService _fakeTracingService; - - private Dictionary _properties; - - /// - /// A default constructor that will use a connection string with name fakexrmeasy-connection to establish a real connection to an environment for integration testing purposes - /// - public XrmRealContext() - { - Init(); - } - - /// - /// A constructor that will use a different connection string name - /// - /// - public XrmRealContext(string connectionStringName) - { - ConnectionStringName = connectionStringName; - Init(); - } - - /// - /// Creates an XrmRealContext that uses the specified IOrganizationService interface - /// - /// - public XrmRealContext(IOrganizationService organizationService) - { - _service = organizationService; - Init(); - } - - /// - /// Initializes common properties across different constructors - /// - private void Init() - { - _properties = new Dictionary(); - _fakeTracingService = new XrmFakedTracingService(); - CallerProperties = new CallerProperties(); - } - - /// - /// - /// - /// - /// - public bool HasProperty() - { - return _properties.ContainsKey(typeof(T).FullName); - } - - /// - /// - /// - /// - /// - /// - public T GetProperty() - { - if(!_properties.ContainsKey(typeof(T).FullName)) - { - throw new TypeAccessException($"Property of type '{typeof(T).FullName}' doesn't exists"); - } - - return (T) _properties[typeof(T).FullName]; - } - - /// - /// - /// - /// - /// - public void SetProperty(T property) - { - if(!_properties.ContainsKey(typeof(T).FullName)) - { - _properties.Add(typeof(T).FullName, property); - } - else - { - _properties[typeof(T).FullName] = property; - } - } - - /// - /// Returns the internal organization service reference - /// - /// - public IOrganizationService GetOrganizationService() - { - if (LicenseContext == null) - { - throw new LicenseException("Please, you need to choose a FakeXrmEasy license. More info at https://dynamicsvalue.github.io/fake-xrm-easy-docs/licensing/licensing-exception/"); - } - - if (_service != null) - return _service; - - _service = GetOrgService(); - return _service; - } - - /// - /// - /// - /// - /// - protected IOrganizationService GetOrgService() - { - var connection = ConfigurationManager.ConnectionStrings[ConnectionStringName]; - - // In case of missing connection string in configuration, - // use ConnectionStringName as an explicit connection string - var connectionString = connection == null ? ConnectionStringName : connection.ConnectionString; - - if (string.IsNullOrWhiteSpace(connectionString)) - { - throw new Exception("The ConnectionStringName property must be either a connection string or a connection string name"); - } - - // Connect to the CRM web service using a connection string. -#if FAKE_XRM_EASY_NETCORE - var client = new CdsServiceClient(connectionString); -#elif FAKE_XRM_EASY_2016 || FAKE_XRM_EASY_365 || FAKE_XRM_EASY_9 - var client = new CrmServiceClient(connectionString); -#else - CrmConnection crmConnection = CrmConnection.Parse(connectionString); - var client = new OrganizationService(crmConnection); -#endif - return client; - } - - /// - /// Returns a default ITracingService that will store all traces In-Memory - /// - /// - public IXrmFakedTracingService GetTracingService() - { - return _fakeTracingService; - } - } -} diff --git a/tests/DataverseEntities/Entities/dv_test.cs b/tests/DataverseEntities/Entities/dv_test.cs index cc1c6f2a..410a2de2 100644 --- a/tests/DataverseEntities/Entities/dv_test.cs +++ b/tests/DataverseEntities/Entities/dv_test.cs @@ -14,7 +14,7 @@ namespace DataverseEntities [System.Runtime.Serialization.DataContractAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("Dataverse Model Builder", "2.0.0.6")] - public enum dv_test_dv_choice_multiple + public enum dv_test_dv_choice { [System.Runtime.Serialization.EnumMemberAttribute()] @@ -29,7 +29,7 @@ public enum dv_test_dv_choice_multiple [System.Runtime.Serialization.DataContractAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("Dataverse Model Builder", "2.0.0.6")] - public enum dv_test_dv_choice_single + public enum dv_test_dv_choice_multiple { [System.Runtime.Serialization.EnumMemberAttribute()] @@ -43,7 +43,7 @@ public enum dv_test_dv_choice_single } /// - /// Status of the Test Table + /// Status of the DV Test Table /// [System.Runtime.Serialization.DataContractAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("Dataverse Model Builder", "2.0.0.6")] @@ -58,7 +58,7 @@ public enum dv_test_statecode } /// - /// Reason for the status of the Test Table + /// Reason for the status of the DV Test Table /// [System.Runtime.Serialization.DataContractAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("Dataverse Model Builder", "2.0.0.6")] @@ -95,10 +95,11 @@ public partial class Fields public const string dv_accountidYomiName = "dv_accountidyominame"; public const string dv_bool = "dv_bool"; public const string dv_boolName = "dv_boolname"; + public const string dv_choice = "dv_choice"; public const string dv_choice_multiple = "dv_choice_multiple"; public const string dv_choice_multipleName = "dv_choice_multiplename"; - public const string dv_choice_single = "dv_choice_single"; - public const string dv_choice_singleName = "dv_choice_singlename"; + public const string dv_choiceName = "dv_choicename"; + public const string dv_code = "dv_code"; public const string dv_currency = "dv_currency"; public const string dv_currency_Base = "dv_currency_base"; public const string dv_customerid = "dv_customerid"; @@ -112,6 +113,10 @@ public partial class Fields public const string dv_file = "dv_file"; public const string dv_file_Name = "dv_file_name"; public const string dv_float = "dv_float"; + public const string dv_fullimage = "dv_fullimage"; + public const string dv_fullimage_Timestamp = "dv_fullimage_timestamp"; + public const string dv_fullimage_URL = "dv_fullimage_url"; + public const string dv_fullimageId = "dv_fullimageid"; public const string dv_image = "dv_image"; public const string dv_image_Timestamp = "dv_image_timestamp"; public const string dv_image_URL = "dv_image_url"; @@ -122,7 +127,7 @@ public partial class Fields public const string dv_string = "dv_string"; public const string dv_testId = "dv_testid"; public const string Id = "dv_testid"; - public const string dv_textarea = "dv_textarea"; + public const string dv_text_area = "dv_text_area"; public const string dv_ticker_symbol = "dv_ticker_symbol"; public const string dv_time_zone = "dv_time_zone"; public const string dv_url = "dv_url"; @@ -152,9 +157,12 @@ public partial class Fields public const string TransactionCurrencyIdName = "transactioncurrencyidname"; public const string UTCConversionTimeZoneCode = "utcconversiontimezonecode"; public const string VersionNumber = "versionnumber"; - public const string dv_account_dv_test_393 = "dv_account_dv_test_393"; - public const string dv_contact_dv_test_393 = "dv_contact_dv_test_393"; + public const string dv_test_FileAttachments = "dv_test_FileAttachments"; + public const string dv_test_Contact_Contact = "dv_test_Contact_Contact"; + public const string dv_account_dv_test_365 = "dv_account_dv_test_365"; + public const string dv_contact_dv_test_365 = "dv_contact_dv_test_365"; public const string dv_test_accountid_account = "dv_test_accountid_account"; + public const string FileAttachment_dv_test_dv_file = "FileAttachment_dv_test_dv_file"; } /// @@ -171,7 +179,7 @@ public dv_test() : public const string EntitySetName = "dv_tests"; - public const int EntityTypeCode = 10359; + public const int EntityTypeCode = 10319; /// /// Unique identifier of the user who created the record. @@ -347,6 +355,19 @@ public string dv_boolName } } + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_choice")] + public virtual dv_test_dv_choice? dv_choice + { + get + { + return ((dv_test_dv_choice?)(EntityOptionSetEnum.GetEnum(this, "dv_choice"))); + } + set + { + this.SetAttributeValue("dv_choice", value.HasValue ? new Microsoft.Xrm.Sdk.OptionSetValue((int)value) : null); + } + } + #if FAKE_XRM_EASY_9 [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_choice_multiple")] public virtual System.Collections.Generic.IEnumerable dv_choice_multiple @@ -360,6 +381,7 @@ public virtual System.Collections.Generic.IEnumerable("dv_code"); + } + set + { + this.SetAttributeValue("dv_code", value); + } + } + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_currency")] public Microsoft.Xrm.Sdk.Money dv_currency { @@ -542,7 +564,7 @@ public string dv_email } } - #if FAKE_XRM_EASY_9 + #if FAKE_XRM_EASY_9 [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_file")] public object dv_file { @@ -551,7 +573,6 @@ public object dv_file return this.GetAttributeValue("dv_file"); } } - #endif [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_file_name")] public string dv_file_Name @@ -568,6 +589,7 @@ public string dv_file_Name } } } + #endif [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_float")] public System.Nullable dv_float @@ -582,6 +604,51 @@ public System.Nullable dv_float } } + #if !FAKE_XRM_EASY + /// + /// An image column that can store full images + /// + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_fullimage")] + public byte[] dv_fullimage + { + get + { + return this.GetAttributeValue("dv_fullimage"); + } + set + { + this.SetAttributeValue("dv_fullimage", value); + } + } + #endif + + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_fullimage_timestamp")] + public System.Nullable dv_fullimage_Timestamp + { + get + { + return this.GetAttributeValue>("dv_fullimage_timestamp"); + } + } + + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_fullimage_url")] + public string dv_fullimage_URL + { + get + { + return this.GetAttributeValue("dv_fullimage_url"); + } + } + + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_fullimageid")] + public System.Nullable dv_fullimageId + { + get + { + return this.GetAttributeValue>("dv_fullimageid"); + } + } + #if !FAKE_XRM_EASY [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_image")] public byte[] dv_image @@ -713,16 +780,16 @@ public override System.Guid Id } } - [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_textarea")] - public string dv_textarea + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_text_area")] + public string dv_text_area { get { - return this.GetAttributeValue("dv_textarea"); + return this.GetAttributeValue("dv_text_area"); } set { - this.SetAttributeValue("dv_textarea", value); + this.SetAttributeValue("dv_text_area", value); } } @@ -1016,7 +1083,7 @@ public Microsoft.Xrm.Sdk.EntityReference OwningUser } /// - /// Status of the Test Table + /// Status of the DV Test Table /// [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statecode")] public virtual dv_test_statecode? statecode @@ -1048,7 +1115,7 @@ public string statecodeName } /// - /// Reason for the status of the Test Table + /// Reason for the status of the DV Test Table /// [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("statuscode")] public virtual dv_test_statuscode? statuscode @@ -1155,6 +1222,22 @@ public System.Nullable VersionNumber } } + /// + /// 1:N dv_test_FileAttachments + /// + [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("dv_test_FileAttachments")] + public System.Collections.Generic.IEnumerable dv_test_FileAttachments + { + get + { + return this.GetRelatedEntities("dv_test_FileAttachments", null); + } + set + { + this.SetRelatedEntities("dv_test_FileAttachments", null, value); + } + } + /// /// N:N dv_test_Contact_Contact /// @@ -1172,36 +1255,36 @@ public System.Collections.Generic.IEnumerable dv_test } /// - /// N:1 dv_account_dv_test_393 + /// N:1 dv_account_dv_test_365 /// [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_customerid")] - [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("dv_account_dv_test_393")] - public DataverseEntities.Account dv_account_dv_test_393 + [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("dv_account_dv_test_365")] + public DataverseEntities.Account dv_account_dv_test_365 { get { - return this.GetRelatedEntity("dv_account_dv_test_393", null); + return this.GetRelatedEntity("dv_account_dv_test_365", null); } set { - this.SetRelatedEntity("dv_account_dv_test_393", null, value); + this.SetRelatedEntity("dv_account_dv_test_365", null, value); } } /// - /// N:1 dv_contact_dv_test_393 + /// N:1 dv_contact_dv_test_365 /// [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_customerid")] - [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("dv_contact_dv_test_393")] - public DataverseEntities.Contact dv_contact_dv_test_393 + [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("dv_contact_dv_test_365")] + public DataverseEntities.Contact dv_contact_dv_test_365 { get { - return this.GetRelatedEntity("dv_contact_dv_test_393", null); + return this.GetRelatedEntity("dv_contact_dv_test_365", null); } set { - this.SetRelatedEntity("dv_contact_dv_test_393", null, value); + this.SetRelatedEntity("dv_contact_dv_test_365", null, value); } } @@ -1221,6 +1304,19 @@ public DataverseEntities.Account dv_test_accountid_account this.SetRelatedEntity("dv_test_accountid_account", null, value); } } + + /// + /// N:1 FileAttachment_dv_test_dv_file + /// + [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dv_file")] + [Microsoft.Xrm.Sdk.RelationshipSchemaNameAttribute("FileAttachment_dv_test_dv_file")] + public DataverseEntities.FileAttachment FileAttachment_dv_test_dv_file + { + get + { + return this.GetRelatedEntity("FileAttachment_dv_test_dv_file", null); + } + } } } #pragma warning restore CS1591 diff --git a/tests/FakeXrmEasy.Core.Tests/Middleware/Crud/FakeMessageExecutors/BulkOperations/UpdateMultipleRequestTests.cs b/tests/FakeXrmEasy.Core.Tests/Middleware/Crud/FakeMessageExecutors/BulkOperations/UpdateMultipleRequestTests.cs index 749bed44..93594458 100644 --- a/tests/FakeXrmEasy.Core.Tests/Middleware/Crud/FakeMessageExecutors/BulkOperations/UpdateMultipleRequestTests.cs +++ b/tests/FakeXrmEasy.Core.Tests/Middleware/Crud/FakeMessageExecutors/BulkOperations/UpdateMultipleRequestTests.cs @@ -349,6 +349,39 @@ public void Should_update_two_records_in_update_multiple() Assert.Equal("Record 1", updatedRecord1["dv_string"]); Assert.Equal("Record 2", updatedRecord2["dv_string"]); } + + [Fact] + public void Should_throw_exception_in_update_multiple_when_using_an_alternate_key_without_a_primary_key() + { + var guid1 = _service.Create(new dv_test(){ dv_code = "C0001"}); + var guid2 = _service.Create(new dv_test() { dv_code = "C0002"}); + + List recordsToUpdate = new List() + { + new dv_test() + { + dv_code = "C0001", + dv_string = "Record 1" + }, + new dv_test() { + dv_code = "C0002", + dv_string = "Record 2" + } + }; + + var entities = new EntityCollection(recordsToUpdate) + { + EntityName = dv_test.EntityLogicalName + }; + + var request = new UpdateMultipleRequest() + { + Targets = entities + }; + + var ex = XAssert.ThrowsFaultCode(ErrorCodes.ObjectDoesNotExist, () => _service.Execute(request)); + Assert.Equal($"Entity Id must be specified for Operation", ex.Detail.Message); + } } } #endif \ No newline at end of file diff --git a/tests/FakeXrmEasy.Core.Tests/XrmRealContextTests/XrmRealContextTests.cs b/tests/FakeXrmEasy.Core.Tests/XrmRealContextTests/XrmRealContextTests.cs deleted file mode 100644 index 4944d4e3..00000000 --- a/tests/FakeXrmEasy.Core.Tests/XrmRealContextTests/XrmRealContextTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -using FakeXrmEasy.Abstractions.Enums; -using FakeXrmEasy.Abstractions.Exceptions; -using System; -using Xunit; - -namespace FakeXrmEasy.Core.Tests.XrmRealContextTests -{ - public class XrmRealContextTests: FakeXrmEasyTestsBase - { - private readonly XrmRealContext _realContext; - - public XrmRealContextTests() : base() - { - _realContext = new XrmRealContext(_service); - _realContext.LicenseContext = FakeXrmEasyLicense.RPL_1_5; - } - - private class CustomProperty - { - - } - - [Fact] - public void Should_connect_to_CRM_with_given_ConnectionString() - { - var ctx = new XrmRealContext("myfirstconnectionstring"); - Assert.Equal("myfirstconnectionstring", ctx.ConnectionStringName); - } - - [Fact] - public void Should_return_service_that_was_injected_in_the_constructor() - { - Assert.Equal(_service, _realContext.GetOrganizationService()); - } - - [Fact] - public void Should_set_property() - { - var customProperty = new CustomProperty(); - _realContext.SetProperty(customProperty); - - Assert.True(_realContext.HasProperty()); - - var property = _realContext.GetProperty(); - Assert.Equal(customProperty, property); - } - - [Fact] - public void Should_throw_type_access_exception_if_property_was_not_found() - { - Assert.Throws(() => _realContext.GetProperty()); - } - - [Fact] - public void Should_update_property_if_it_was_set() - { - var customProperty = new CustomProperty(); - _realContext.SetProperty(customProperty); - - var newProperty = new CustomProperty(); - _realContext.SetProperty(newProperty); - - var property = _realContext.GetProperty(); - Assert.Equal(newProperty, property); - } - - [Fact] - public void Should_return_fake_tracing_service() - { - var tracingService = _realContext.GetTracingService(); - Assert.IsType(tracingService); - } - - [Fact] - public void Should_set_default_caller_properties() - { - Assert.NotNull(_realContext.CallerProperties); - } - - [Fact] - public void Should_return_license_exception_if_not_set_when_getting_an_organization_service() - { - var ctx = new XrmRealContext(_service); - Assert.Throws(() => ctx.GetOrganizationService()); - } - } -} \ No newline at end of file