Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used current record definitions #646

Open
wants to merge 16 commits into
base: development
Choose a base branch
from

Conversation

DocSvartz
Copy link

@DocSvartz DocSvartz commented Oct 23, 2023

Fix Issue:
#501 - test named OnlyInlineRecordWorked (regarding not filling the record with data in the given case)

Add

  1. (InlineExpression is Worked) Field Activation passing Field values not specified in the constructor when creating a new record instance
  2. Record Creation on Default Passing Field values not specified in the constructor when creating a new record instance (Activation)
  3. A special attribute to support custom classes (structures) that use the current record definition. description of spec record at the end of the page -
    [AdaptWith(AdaptDirectives.DestinationAsRecord)] - to be confirmed

Example:

 [TestMethod]
        public void MultiCtorAndInlineRecordWorked()
        {
            var _sourcePoco = new MultiCtorAndInlinePoco() { MyInt = 1, MyString = "Hello", MyEmail = "123@gmail.com", InitData="Test"};
            var _sourceMultiCtorAndInline = new MultiCtorAndInlineRecord(2, "Hello World") { InitData = "Worked", MyEmail = "243@gmail.com" };

            var _resultMultiCtorAndInline = _sourcePoco.Adapt<MultiCtorAndInlineRecord>();  // Activation 
            var _updateResult = _sourceMultiCtorAndInline.Adapt(_resultMultiCtorAndInline);  // Update

            _resultMultiCtorAndInline.MyInt.ShouldBe(1);
            _resultMultiCtorAndInline.MyString.ShouldBe("Hello");
            _resultMultiCtorAndInline.MyEmail.ShouldBe("123@gmail.com");
            _resultMultiCtorAndInline.InitData.ShouldBe("Test");
            _updateResult.MyInt.ShouldBe(2);
            _updateResult.MyString.ShouldBe("Hello World");
            _updateResult.MyEmail.ShouldBe("243@gmail.com");
            _updateResult.InitData.ShouldBe("Worked");
        }

    record MultiCtorAndInlineRecord
    {
        public MultiCtorAndInlineRecord(int myInt)
        {
            MyInt = myInt;
        }

        public MultiCtorAndInlineRecord(int myInt, string myString) : this(myInt) // default have been using this constructor
        {
            MyString = myString;
        }


        public int MyInt { get; private set; } // private set only constructor or using init 
        public string MyString { get; private set; } // private set only constructor or using init 
        public string MyEmail { get; set; } 
        public string InitData { get; init; } // init in Constructor or inline activation
    }

@DocSvartz DocSvartz changed the title FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attibute from support used legasy record definitions FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used legasy record definitions Oct 23, 2023
@DocSvartz
Copy link
Author

DocSvartz commented Oct 23, 2023

Explanations regarding tests marked Ignore
I don’t understand what exactly wanted to check in them?

  1. If it is possible to map non-public fields to the record constructor, then the Source should have had them
  2. If mapping fields from the Source to hidden fields in the record, then this should not work at all. The record is always activated through the constructor and they would have gotten there anyway. Because the sources are public.

Tests have been rewritten to test what the test name states

@DocSvartz DocSvartz changed the title FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used legasy record definitions FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used legacy record definitions Oct 23, 2023
@DocSvartz DocSvartz changed the title FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used legacy record definitions FIx Issue #537 - Step 2 - Add Support Extended Record Function + Attribute from support used current record definitions Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant