mocking - How to prevent a call to the data layer from a mocked object -
Text after "div class =" itemprop = "text">
I have a business objective that I am joking about testing for business (using the Moq). When I call the object, it calls another business object that goes to the data layer. I have the objective that I can set a return for calls within the written, but how can I prevent it from calling other objects and moving into the data layer?
Is there a standard practice to stop this? Apologies if this is not clear enough; I will answer those questions as I have been asked! Thank you
An example of a code here, simplified is just a bit:
Business Test
In the form of a slow mockPer New Fake (IYTDMarketShrink) Create items for use in 'DLL Kolling' test as new cConfiguration cConfig.Environment = Ent.MeijerEnvironmentEnum.DEVELOPMENT as new Clogger Production Deccoconfig. New system as demat test data. DataDetDetestadata RedXLSKema ("MarketSpreadDataAxAsd") Dstestadata .ReadXml ("MarketShrinkPerTestData.xml") 'Returns to the IYTDMarketShrink Data Layer Dim Targets New CMarketShrinkPer (CTYPE (mockPer.Object, IYTDMarketShrink), jam, cConfig) FiscalYear = 2009 to specify parameter values for the target .FiscalPeriod = 9 target.ReportType = "CPPTS" 'set the return value of a joke made function, (IYTDMarketShrink as X) x.dsGetPeriodShrinkDetails (target.FiscalYear, target.FiscalPeriod phone function MockPer.Setup (function, 'C')). Returns (dsTestData) result = target.dtGetPeriodShrinks () as MockPerkVerify (function (x IYTDMarketShrink) x.dsGetPeriodShrinkDetails (target.FiscalYear, target.FiscalPeriod, 'C')) Assert.AreEqual (results not. Rows.Count , 9)
method business being called object:
public function dtGetPeriodShrinks () Try DataTable GetReportBody () return catch dtTotalShrink As an exemption, try the second end function with the exception m_cLogging.LogError (formerly, "CMarketShrinkPer.vb: dtGetPeroidShrinks")
and that's me The giving by trouble on the object, the method in question is nothing Under the code (objGeneral.GetInvalidStores ()):
private sub GetReportBody () Dim dsShrinkdetails datasets = dim the dvShrink DataView = nothing dim drShrink DataRow = nothing dim intCurRgn as as as as int16 dim IntPrevRgn int16 dim strRegio as n string = String.Empty dim intCount integer dim intMarketCount Form integer dim strOrgHcy string = String.Empty dim strInvalidStores string = String.Empty slow drNewRow Dat ARow = nothing is dim cGeneral IGeneral = nothing is slow objGeneral CGeneral = nothing as as as try as cgeneral = new cGeneralData (m_cLogging, m_cConfig) objGeneral = new CGeneral (cGeneral, m_cLogging) If Me.ReportType = m_strCURRENT_PERIOD_SHRINK then dsShrinkdetails = m_cMarketShrink.dsGetPeriodShrinkDetails (Me.FiscalYear, Me.FiscalPeriod, m_strCURRENT_PERIOD) elseif Me.ReportType = m_strLAST_PERIOD_SHRINK then dsShrinkdetails = Msimkeket Srinkkdijetperiodsrikadit (May. Fic. Year, m. Fiskalpierod, M_STRLAS-PRIID) Otherwise. Type Report = M_striti Seediaiacaraianke then Disarnnkakshn = Maisimaartimaarsi.aksjitiaiteedisiarseediadit (Mifsisiaiar, Mkfiklikperiod) is if it does not Disarnkindijet end and nothing besides dsShrinkdetails.Tables.Count & gt; 6 then m_dtShrinkales = dsShrinkdetails.Tables (table.Synchronous) m_dtStockLoss = dsShrinkdetails.Tables (table. Stoploss) m_dtThrowAways = dsShrinkdetails.Tables (table towerhouse) m_dtMarkDowns = dsShrinkdetails.Tables (table. Markdown) m_dtGasDriveOff = dsShrinkdetails.Tables (table. Gaaviveoff) m_dtCashOverShort = dsShrinkdetails.Tables (table.CastOverShort) m_dtTotalShrinkAmt = dsShrinkdetails.Tables (table totalConnect) with objGeneral .fiscalYear = Me.FiscalYear .fiscalPeriod = Me.FiscalPeriod End 'with strInvalidStores = objGeneral to obtain invalid stores. GetInvalidStores ()
Comments
Post a Comment