I have the below code:public interface IRepositoryService{    /// <summary>    /// This will add conditions like Published = true, Deleted = false and PublisehdDate smaller than NOW    ///     /// </summary>    IRavenQueryable<T> AddConditionsToQueryToLoadOnlyAvailableForFrontend<T>(IRavenQueryable<T> query) where T : BaseObject;}public class HomepageBannerRepository : BaseRepository<HomepageBanner>, IHomepageBannerRepository{    public HomepageBannerRepository(IRepositoryService repositoryService)        : base(repositoryService)    {    }    public List<HomepageBanner> GetHomepageBanners()    {        var q = CreateQuery(loadOnlyItemsAvailableToFrontend: true, autoSortByPriority: true);        var list = q.ToList();        return list;    }}The method IRepositoryService.AddConditionsToQueryToLoadOnlyAvailableForFrontend() adds general conditions to any query like Published=True and Deleted=False, as all my objects inherit from BaseObject which contains fields like Published, Deleted etc.This has been tested, and for the method HomepageBannerRepository.GetHomepageBanners(), I would only like to verify that it was called (using mocks), rather than having to check via unit-testing that only published items are returned.The current unit test I created is as below (using the SpecsFor framework)        [TestFixture]        public class GetHomepageBannerSpecs        {            [TestFixture]            public class when_method_is_called : SpecsForRepository<HomepageBannerRepository>            {                private HomepageBanner _bannerA;                private HomepageBanner _bannerB;                private HomepageBanner _bannerC;                private List<HomepageBanner> _results;                private HomepageBanner createHomepageBanner()                {                    HomepageBanner banner = new HomepageBanner();                    banner.Store();                    return banner;                }                protected override void Given()                {                    _bannerA = createHomepageBanner();                    _bannerB = createHomepageBanner();                    _bannerC = createHomepageBanner();                    GetMockFor<IRepositoryService>();                    base.Given();                }                protected override void When()                {                    _results = SUT.GetHomepageBanners();                    base.When();                }                [Test]                public void then_it_should_return_all_homepage_banners()                {                    GetMockFor<IRepositoryService>().Verify(x => x.AddConditionsToQueryToLoadOnlyAvailableForFrontend(It.IsAny<IRavenQueryable<HomepageBanner>>()), Times.Once());                    GetMockFor<IRepositoryService>().Verify(x => x.AddSortByPriorityToQuery(It.IsAny<IRavenQueryable<HomepageBanner>>()), Times.Once());                    _results.ShouldContain(_bannerA);                    _results.ShouldContain(_bannerB);                    _results.ShouldContain(_bannerC);                }            }        }The main problem stems from that the actual implementation of HomepageBannerRepository.GetHomepageBanners() requires that the implementation of the IRepositoryService returns a query, when IRepositoryService.AddConditionsToQueryToLoadOnlyAvailableForFrontend is called.  Since I am using a mock, this returns NULL, and then it throws an ObjectNullReference exception.First of all, is it possible to setup the Mock to return the same parameter passed as input parameter? Something like:GetMockFor(IRepositoryService).Setup(x=>x.AddConditionsToQueryToLoadOnlyAvailableForFrontend(query)).Returns(query); I am using Moq as my mocking framework.Also, I would like to receive any criticism regarding code, and where it could be structured better with regards to unit-testing / Test-Driven Development, dependency injection and any other comments are greatly welcome.
Mock/unit test for this IRepositoryService method/class
c#;unit testing;dependency injection;moq