DataPortal_Create method

DataPortal_Create method

Old forum URL: forums.lhotka.net/forums/t/11976.aspx


tom posted on Friday, May 10, 2013

I am using the CSLA 3.x framework.

This is my Unit Test method for the DataProtal Create method for one of our business objects.  Should I add anymore to it?

        /// <summary>
        ///A test for DataPortal_Create
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Cit.Library.dll")]
        public void DataPortal_CreateTest()
        {
            Person person = Person.GetPerson(false, 1);

            Cit_Accessor target = new Cit_Accessor();
            object criteria = new Cit_Accessor.Criteria(1, Person);

            target.DataPortal_Create(criteria);

            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

RockfordLhotka replied on Friday, May 10, 2013

To create a valid unit test one must understand the purpose of the method being tested.

DataPortal_Create has a singular purpose: initialize the values of a new object graph.

As a result, I would expect your "Inconclusive" assertion to be replaced with asserts that establish that the new object graph was properly initialized based on your business requirements.

Please note that because you have bypassed the entire data portal infrastructure your test is only somewhat valid. Many DataPortal_XYZ methods rely on the context provided by the data portal (such as being in a transaction, etc.) and so your tests must take into account that the way you are calling the method is not the same as if it were invoked via the data portal pipeline.

Copyright (c) Marimer LLC