public void RentItemReturnRented() { var data = new List <Item> { new Item { Id = 1, Name = "First" } }.AsQueryable(); var mockSet = new Mock <DbSet <Item> >(); mockSet.As <IQueryable <Item> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Item> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Item> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Item> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock <SkiResortContext>(); mockContext.Setup(c => c.Items).Returns(mockSet.Object); var controller = new RentalController(mockContext.Object); var item = controller.GetItem(1); controller.RentItem(item.Id); Assert.AreEqual("Rented", item.Status); }