Copied to clipboard

Flag this post as spam?

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


  • Brendan Rice 538 posts 1102 karma points
    Aug 10, 2010 @ 13:15
    Brendan Rice
    0

    Umbraco Membership Problem

    I have a complex custom member type that has a lot of associated properties

    MyComplexMember
     |- Id (int)
     |- LastName (string)
     |- FirstName (string)
     |- CustomObjectList (List<MyCustomObject>)
     
    The member needs to be this complicated as it is used in a calculation engine.  Due to the complexity I have written tests around the logic and this means I have a safety net to ensure the calculation is correct.

    There are a few things I am struggling with:

    1. How best to tie my MyComplexMember to umbraco, I have read the following article but it only deals with simple objects (i.e. strings) and I need to know how to handle generic Lists of custom objects.

    http://www.aaron-powell.com/umbraco-members-profiles

    2. If I use the above approach and make my object inherit from System.Web.Profile.ProfileBase the I will need Umbraco configuration to set up the profiles etc and this will couple my tests to the umbraco database which I really don't want.

    3. I need to be able to run simple reporting off the properties of the MyComplexMember and don't know how best to go about this if Umbraco is holding all the values in XML in the DB.


    It would be great to get some pointers with these questions,

    Thanks in advance,

    B

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 10, 2010 @ 13:35
    Aaron Powell
    0

    Here's an MSDN article on how to work with ASP.NET profiles, it also includes info on complex types: http://msdn.microsoft.com/en-us/library/d8b58y5d.aspx

    As for how you then put this in with Umbraco you would probably need a custom data type which you can use to display the info in the Umbraco back end. The data type can be designed to serialize/ deserialize XML too so you can work with it.

    I'm pretty sure that the member info isn't stored as XML though, I know it's not stored outside of the database, that'd be a bit crazy a security problem :P

  • Brendan Rice 538 posts 1102 karma points
    Aug 10, 2010 @ 14:08
    Brendan Rice
    0

    Thanks for the reply Slace.  I was reading you blgo and noticed you are familiar with unit testing.  So if I am tightly coupling my member class to the ASP.Net membership provider that hooks into Umbraco which in turn hits the database this goes against unit testing principles.  How can I break the coupling between my code and umbraco?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 11, 2010 @ 00:55
    Aaron Powell
    0

    Do you need to test the saving of your profiles, shouldn't that be expected to work through the underlying provider?

    If you're using WebForms MVP though you can stub the HttpContext.Profile object and then access that in your presenter.

  • Brendan Rice 538 posts 1102 karma points
    Aug 11, 2010 @ 11:03
    Brendan Rice
    0

    I was going to inherit the ProfileBase on a Member DTO type object I have, all it is used for is transfering data with a little bit fo logic (i.e. get age from birth date).

    The problem is when I do this I will need to add in config settings into the test assembly for testing the Profile as it is hooked into ASP.Net membership.


    Any ideas as to how best break that dependency and insert a "seam"?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Aug 11, 2010 @ 13:52
    Aaron Powell
    0

    It's somewhat on oxymoron having your DTO inherit from ProfileBase, you'd then be coupling a descoped class to a highly scoped base class.

    I can't think of any kind of implementation which would let you completely DTO a profile using the ASP.Net membership.

    Using WebForms MVP and any mocking framework you can create a stub version of a profile provider and a bunch of stuff around it. That's how you'd do your unit test, integration testing is a whole different problem though :P

Please Sign in or register to post replies

Write your reply to:

Draft