public void CountSections() { Mock<ISectionRepository> mock = new Mock<ISectionRepository>(); mock.Setup(a=>a.Sections).Returns(new Section[] { new Section { id = 1, short_name = "IMZ1" }, new Section { id = 2, short_name = "IMZ2" }, new Section { id = 3, short_name = "IMZ3" }, new Section { id = 4, short_name = "IMR1" }, new Section { id = 5, short_name = "IMR2" } }.AsQueryable()); SectionController ctrl = new SectionController(mock.Object); int count = ctrl.CountSections(); Assert.IsNotNull(count); Assert.AreEqual(ctrl.CountSections(), 5); }