public void GetAllContractors() { Mock<IContractorRepository> mock = new Mock<IContractorRepository>(); mock.Setup(a => a.Contractors).Returns(new Contractor[] { new Contractor { id = 1, name = "Firma1" }, new Contractor { id = 2, name = "Firma2" }, new Contractor { id = 3, name = "Firma3" }, new Contractor { id = 4, name = "Firma4" }, new Contractor { id = 5, name = "Firma5" }, new Contractor { id = 6, name = "Firma6" } }.AsQueryable()); ContractorController ctrl = new ContractorController(mock.Object); Object[] temp = ctrl.GetAllContractors(); Assert.AreEqual(temp.Length, 6); Assert.AreEqual(((Contractor)temp[3]).name, "Firma4"); }