jordimontana82 / fake-xrm-easy

The testing framework for Dynamics CRM and Dynamics 365 which runs on an In-Memory context and deals with mocks or fakes for you
https://dynamicsvalue.com/get-started/overview?source=git
Other
263 stars 182 forks source link

Min Date allowed in CRM is 01/01/1753 00:00:00, however fake xrm easy allows 01/01/0001 00:00:00 #562

Open dikshitdhawan87 opened 3 years ago

dikshitdhawan87 commented 3 years ago

Bug Description If you try to create a record in CRM where a DateTime Field's value is set to any date < 01/01/1753 00:00:00 Then CRM throws an error - Microsoft.Xrm.Sdk.Entity Exception Details: DateTime is less than minimum value supported by CrmDateTime. Actual value: {value provided}, Minimum value supported: 01/01/1753 00:00:00

Fake Xrm Easy should behave the same way so that we can write units tests around the functionality. Currently Fake Xrm Easy does not throw any exception if the provided DateTime Value is less than "01/01/1753 00:00:00" and works fine(i.e. creates the record) => hence not mimicking the actual behavior of CRM

To Reproduce //C# Code

        private static CrmServiceClient _service;
        string url = "**********************";  // e.g. https://yourorg.crm.dynamics.com
        string userName = "*****************";  // e.g. you@yourorg.onmicrosoft.com
        string password = "********";          // e.g. y0urp455w0rd 

        string conn = $@"
            Url = {url};
            AuthType = OAuth;
            UserName = {userName};
            Password = {password};
            LoginPrompt=Auto;
            RequireNewInstance = True";

        _service = new CrmServiceClient(conn);
        var contactToBeCreated = new Entity("contact");
        contactToBeCreated["birthdate"] = DateTime.MinValue;
        try
        {
            var recordId = _service.Create(contactToBeCreated);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

Expected behavior An exception should be thrown "Date is less than the minumum value supported by CrmDateTime. Actual value: 01/01/0001 00:00:00, Minimum value supported: 01/01/1753 00:00:00"

FakeXrmEasy and Dynamics 365 / CRM version FakeItEasy | version="6.0.0" FakeXrmEasy.9 | version="1.57.1"

D365 - V9.2

jordimontana82 commented 3 years ago

Thanks for reporting this. Did you have a chance to try if this happens in earlier versions of CRM as well?

dikshitdhawan87 commented 3 years ago

This is how CRM behaves in earlier versions as well i.e minn date for CRM is 01/01/1753 00:00:00 And not 01/01/0001 00:00:00

On Wed, 2 Jun 2021, 21:21 Jordi, @.***> wrote:

Thanks for reporting this. Did you have a chance to try if this happens in earlier versions of CRM as well?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jordimontana82/fake-xrm-easy/issues/562#issuecomment-853143112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AREY2AAV7HYGOX4G35WJGBLTQZHRHANCNFSM4567SJNA .