I think you're already asking yourself the right question: what exactly are you trying to test here? It can't be the results returned from the query since you're telling the mock object what to return from the UpdateAccount(...) invocation. From my reading, I agree with your estimation that all you're really doing here is testing the mocking framework (which obviously is already well-tested <g>).
Some ideas about what you *might* want to test here include: - is the call happening in a transaction? - are the right parameters being added to your query before its invocation? These are probably going to be somewhat challenging to inspect given the manner in which the system under test (SUT) is presently designed, but from my first glance at this class/method, they are about the only (useful) things to test here. One thing that you *could* consider doing is this: 1. redesign the SUT to inject the IConnectionHelper instance into the class rather than having the class call DataConnection.GetConnection() itself 2. in the test, inject a mock instance of IConnectionHelper 3. for your asserts, asset that the expected calls have been made to the mocked IConnectionHelper instance Since all of the 'behavior' that you would reasonably want to test here is really about your SUT interacting with the IConnectionHelper by mocking that and asserting against it you may be able to verify that a transaction happened, that params were added to the query, etc. Then your test can be more like UpdateAccount_Uses_Transactions(), UpdateAccount_Passes_Expected_Parameters(), etc. This is just a guess about how to approach this b/c I've no idea what IConnectionHelper actually looks like, but its a general suggestion of one way to approach this. Hope this helps. Steve Bohlen [email protected] http://blog.unhandled-exceptions.com http://twitter.com/sbohlen On Tue, Dec 7, 2010 at 11:53 PM, Santy2029 <[email protected]> wrote: > Here is the code: > > public class DALAccounts : IDALAccounts > { > IConnectionHelper factory = DataConnection.GetConnection(); > > public List<Result> UpdateAccount(string accountId, string > accountInfo) > { > List<Result> result = null; > > factory.ExecuteTransaction(tran => > { > tran.ExecuteQuery(query => > { > query.AddParameter(...) > DataReader dr = query.ExecuteReaderWithProc(); > result = dr.GetData<Result>(Result.Map); > }); > }); > > return result; > } > } > > Test Method: > public void UpdateAccountTest() > { > var accountMock = MockRepository.GenerateStub(IDALAccounts); > accountMock.Stub(x => x.UpdateAccount(accountId, > accountInfo)).Return(fakeResultList); > List<Result> results = accountMock.UpdateAccount(accountId, > accountInfo); > Assert.AreEqual(results[0].ReturnValue, "00"); > } > > My concern is I am just calling the mock method and not even getting > inside the actual method. Even if I mock IConnectionHelper, I will be > able to reach code upto ExecuteTransaction but won't go further down. > Am I missing anything?? Is it possible to do something more here?? > > Anyways, ExecuteTransaction and ExecuteQuery are methods from a common > library that takes 1 parameter Action delegates. > > Any help would be highly appreciated!! > > Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Rhino.Mocks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rhinomocks%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rhinomocks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
