Pardon me, I am fairly new to RhinoMocks and mocking in general and I
need some help. I have a factory that creates an instance of a list
object with this method:

public override L Fetch(CriteriaBase criteria)
        {
            if (criteria != null)
            {
                var list = (L) Activator.CreateInstance(typeof (L),
true);
                IList<I> _list;

                using(UnitOfWork.Start(DatabaseKey))
                {
                    NHibernate.ICriteria crit =
_repository.CreateCriteria();

                    list.SetNHibernateCriteria(criteria, crit);
                    _list = crit.List<I>();
                }

                list.RaiseListChangedEvents = false;

                foreach (var item in _list)
                {
                    list.Add(item);
                }

                list.RaiseListChangedEvents = true;
                MarkOld(list);
                return list;

            }
            return Fetch();
        }

I have a test setup like this:

[TestMethod]
        public void
BusinessBaseFactory_Fetch_WithCriteria_ReturnsObject()
        {
            BusinessListBaseServerFactory<ProductList, Product>
_factory = new BusinessListBaseServerFactory<ProductList,
Product>(_repository);
            _criteria = _mocks.DynamicMock<NHibernate.ICriteria>();

            ProductList _returnValues = new ProductList();
            ProductList products = _factory.Create();
            using (_mocks.Record())
            {
                Expect.Call(_repository.CreateCriteria()).Do(new
CriteriaAction(getCriteria));
            }
            using (_mocks.Playback())
            {
                products = _factory.Fetch(new
SingleCriteria<ProductList, string>("Test"));
            }
        }

        private delegate NHibernate.ICriteria CriteriaAction();

        private NHibernate.ICriteria getCriteria()
        {
            _criteria =
UnitOfWork.CurrentSession("PTracker").CreateCriteria(typeof
(Product));
            return _criteria;
        }

This test is successful but it doesn't really test that
ICriteria.List() was called. I am having trouble wrapping my head
around how to test that since the ICriteria variable in the test is a
local instance. Got any ideas?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to