Unable to Run Test Multiple Time With Save Method

Unable to Run Test Multiple Time With Save Method

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

RumbleCow posted on Wednesday, April 23, 2014

Csla 4.3.13 / Visual Studio 2010

I am unable to run test scripts multiple time which contains a call to the save method without rebuilding the solution. If the po.save is commented out in the code below can be run an infinite number of time. If the save is included I receive 'DataPortal.Fetch failed (Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.)' upon the call to  GetVendor.  The PO.Insert is run inside using statements 


        public void _MultiRunDiagnostics()


            PO po = PO.NewPO();

            po.Vendor = ror.Vendor.GetVendor(1);

            po.Number = DateTime.Now.Ticks.ToString().Substring(0, 12);

            po.Date = DateTime.Now;




            Assert.AreEqual<string>(DateTime.Today.ToShortDateString(), po.StatusDate.ToShortDateString());

            PODetailListItem detail = po.DetailLines.AddNew();

            detail.ItemID = 4;

            detail.Quantity = 1;

            Assert.AreEqual<Decimal>(1.01m, detail.Cost);




            // test can be run repeatedly if save is excluded

            po = po.Save();




JonnyBee replied on Thursday, April 24, 2014

Then you must resolve the issues in the GetVendor or the Save method. 

Obviously something is not either inserted into a database (and create duplicates) or there is something wrong with the SQL in Vendor.DataPortal_Fetch.


Copyright (c) Marimer LLC