private void SetupFakeOffers() { var seller = new User() { Id = "123", UserName = "******" }; var fakeOffers = new List<Offer>() { new Offer() { Id = 1, Title = "offer #1", Description = "Desc#1", PublishDate = DateTime.UtcNow, ExpirationDate = DateTime.UtcNow.AddDays(10), InitialPrice = 200m, Seller = seller }, new Offer() { Id = 2, Title = "offer #2", Description = "Desc#2", PublishDate = DateTime.UtcNow, ExpirationDate = DateTime.UtcNow.AddDays(10), InitialPrice = 200m, Seller = seller }, }; this.OfferRepositoryMock = new Mock<IRepository<Offer>>(); this.OfferRepositoryMock.Setup(r => r.All()).Returns(fakeOffers.AsQueryable()); this.OfferRepositoryMock.Setup(r => r.Find(It.IsAny<int>())).Returns( (int id) => { return fakeOffers.FirstOrDefault(o => o.Id == id); }); }
private void SetupFakeBids() { var bidder = new User() { Id = "123", UserName = "******" }; var fakeBids = new List<Bid>() { new Bid() { Id = 1, BidPrice = 220m, DateOfBid = DateTime.UtcNow, Bidder = bidder }, new Bid() { Id = 1, BidPrice = 220m, DateOfBid = DateTime.UtcNow, Bidder = bidder }, new Bid() { Id = 1, BidPrice = 220m, DateOfBid = DateTime.UtcNow, Bidder = bidder }, }; this.BidRepositoryMock = new Mock<IRepository<Bid>>(); this.BidRepositoryMock.Setup(r => r.All()).Returns(fakeBids.AsQueryable()); this.BidRepositoryMock.Setup(r => r.Find(It.IsAny<int>())).Returns( (int id) => { return fakeBids.FirstOrDefault(o => o.Id == id); }); }