public void GetSectionsByPost() { Mock<ISectionRepository> mock = new Mock<ISectionRepository>(); mock.Setup(a => a.Sections).Returns(new Section[] { new Section { id = 1, short_name = "IMZ1" , name = "SEKCJA ZMECHANIZOWANEJ WYMIANY NAWIERZCHNI", post = "Kraków" }, new Section { id = 2, short_name = "IMN", name = "Sekcja Zgrzewania Szyn Kędzierzyn Koźle", post = "Kędzierzyn-Koźle" }, new Section { id = 3, short_name = "IMP", name = "SEKCJA ZMECHANIZOWANEJ WYMIANY PODTORZA", post = "Kraków" }, new Section { id = 4, short_name = "IMR1", name = "Sekcja Robót Inżynieryjnych Skarżysko", post = "Skarżysko-Kamienna" }, new Section { id = 5, short_name = "IMR2", name = "Sekcja Robót Inżynieryjnych Warszawa", post = "Warszawa" } }.AsQueryable()); SectionController ctrl = new SectionController(mock.Object); object[] temp = ctrl.GetSectionsByPost("Warszawa"); Assert.AreEqual(temp.Length, 1); Assert.AreEqual(((Section)temp[0]).short_name, "IMR2"); object[] temp2 = ctrl.GetSectionsByPost("Kraków"); Assert.AreEqual(temp2.Length, 2); Assert.AreEqual(((Section)temp2[1]).short_name, "IMP"); object[] temp3 = ctrl.GetSectionsByPost("Poznań"); Assert.AreEqual(temp3.Length, 0); }