Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Aaron Mitchard 7 posts 47 karma points
    Jan 23, 2015 @ 12:27
    Aaron Mitchard
    0

    Property Mapping - DefaultValue

    Hi again,

    Not sure if this is working, basic setup with matching property names... example:

    [PropertyMapping(DefaultValue = "Confirm")]
    public string ConfirmationButtonText { get; set; }

    My VM doesn't get populated with 'Confirm', its either a null or empty string (which I think is Umbracos default behaviour of GetValue). If I set the value on my page it maps just fine.

    Saw there were a few tests for this (UmbracoMapper_MapFromIPublishedContent_MapsWithStringDefaultValueUsingAttribute) but I can't run the solution and offer a suggestion because 'Microsoft.QualityTools.Testing.Fakes' requires VS Premium/Ultimate I think!? I run Pro, so let me know if there's a way round this! 

    Cheers,
    Aaron.

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jan 23, 2015 @ 22:02
    Andy Butland
    100

    Hi Aaron

    Looks like you're right - I've extended the tests you noted to check for empty string responses (rather than nulls, which works as expected) and they now fail.  So have fixed and updated in the latest version if you pull from NuGet or Our.  Thanks again for the testing and bug report.

    As regard the unit tests, yes, unfortunately I've had to make use of MS Fakes here which, although a great solution, only comes with Premium (and fortunately, I get through work).  I couldn't find another solution for mocking IPublishedContent.  If you're interested, you can read how I came to his here.  Not sure of a way around it - you can add your voice here for getting it in professional.

    Cheers

    Andy

     

  • Aaron Mitchard 7 posts 47 karma points
    Jan 24, 2015 @ 15:42
    Aaron Mitchard
    0

    Cheers Andy and thanks for the links. Can't believe its not available to all versions with Microsofts/.NET's new 'open source' approach. Seems like a good approach though I've only really used Moq here and there in the past and your post clears a few things up I was wondering about.

    Thanks,
    Aaron. 

Please Sign in or register to post replies

Write your reply to:

Draft