public void GetContractorByNip() { Mock<IContractorRepository> mock = new Mock<IContractorRepository>(); mock.Setup(a => a.Contractors).Returns(new Contractor[] { new Contractor { id = 1, nip = 111111 }, new Contractor { id = 2, nip = 222222 }, new Contractor { id = 3, nip = 333333 }, new Contractor { id = 4, nip = 444444 }, new Contractor { id = 5, nip = 555555 }, new Contractor { id = 6, nip = 666666 } }.AsQueryable()); ContractorController ctrl = new ContractorController(mock.Object); Contractor temp = ctrl.GetContractorByNip(444444); Assert.IsNotNull(temp); Assert.AreEqual(temp.id, 4); temp = ctrl.GetContractorByNip(888888); Assert.IsNull(temp); }