public void Get_Current_Rental_Subs() { var asset = new Guitar() { Id = 10, Type = "Bass", Name = "Bass Guitar" }; var subOne = new Subscriber { Id = 1, FirstName = "Jim", LastName = "Brown" }; var subTwo = new Subscriber { Id = 2, FirstName = "Michael", LastName = "James" }; var subThree = new Subscriber { Id = 3, FirstName = "Sarah", LastName = "Shannons" }; var rentals = new List <Rental>() { new Rental { Id = 111, Since = DateTime.Now, Until = DateTime.Now, Subscriber = subOne, RentalAsset = asset }, new Rental { Id = 222, Since = DateTime.Now, Until = DateTime.Now, Subscriber = subTwo, RentalAsset = asset }, new Rental { Id = 333, Since = DateTime.Now, Until = DateTime.Now, Subscriber = subThree, RentalAsset = new Guitar() } }.AsQueryable(); var mockDbSet = new Mock <DbSet <Rental> >(); mockDbSet.As <IQueryable <Rental> >().Setup(p => p.Provider).Returns(rentals.Provider); mockDbSet.As <IQueryable <Rental> >().Setup(p => p.Expression).Returns(rentals.Expression); mockDbSet.As <IQueryable <Rental> >().Setup(p => p.ElementType).Returns(rentals.ElementType); mockDbSet.As <IQueryable <Rental> >().Setup(p => p.GetEnumerator()).Returns(rentals.GetEnumerator); var mockContext = new Mock <RentalContext>(); mockContext.Setup(r => r.Rentals).Returns(mockDbSet.Object); var service = new RentalService(mockContext.Object); var rental = service.GetCurrentRentalSubs(asset.Id); rental.Should().HaveCount(2); rental.Should().Contain("Michael James"); rental.Should().Contain("Jim Brown"); }