public void GetContractorsByCountry() { Mock<IContractorRepository> mock = new Mock<IContractorRepository>(); mock.Setup(a => a.Contractors).Returns(new Contractor[] { new Contractor { id = 1, country = "Polska" }, new Contractor { id = 2, country = "Holandia" }, new Contractor { id = 3, country = "Polska" }, new Contractor { id = 4, country = "Niemcy" }, new Contractor { id = 5, country = "Polska" }, new Contractor { id = 6, country = "Polska" } }.AsQueryable()); ContractorController ctrl = new ContractorController(mock.Object); object[] temp = ctrl.GetContractorsByCountry("Polska"); Assert.AreEqual(temp.Length, 4); Assert.AreEqual(((Contractor)temp[3]).id, 6); temp = ctrl.GetContractorsByCountry("Niemcy"); Assert.AreEqual(temp.Length, 1); Assert.AreEqual(((Contractor)temp[0]).id, 4); temp = ctrl.GetContractorsByCountry("Czechy"); Assert.AreEqual(temp.Length, 0); }