public void TestGet() { Subscription newSubscription = new Subscription() { Id = 3, Value = "Track", Type = "Track" }; //Setup var subscriptions = new List <Subscription>() { newSubscription }; var data = subscriptions.AsQueryable(); var mockSet = setUpAsQueriable(data); mockSet.Setup(d => d.Add(It.IsAny <Subscription>())).Callback <Subscription>((r) => subscriptions.Add(r)); mockSet.Setup(d => d.Remove(It.IsAny <Subscription>())).Callback <Subscription>((r) => subscriptions.Remove(r)); var mockContext = new Mock <TweetContext>(); mockContext.Setup(c => c.Subscriptions).Returns(mockSet.Object); // Arrange SubscriptionDBRepository repo = new SubscriptionDBRepository(mockContext.Object); // Act var result = repo.Get(newSubscription.Id); // Assert Assert.Equal(result, newSubscription); }
public void CheckTwitterId() { Subscription newSubscription = new Subscription() { Id = 3, Value = "Track", Type = "Track" }; //Setup var subscriptions = new List <Subscription>() { newSubscription }; var data = subscriptions.AsQueryable(); var mockSet = setUpAsQueriable(data); var mockContext = new Mock <TweetContext>(); mockContext.Setup(c => c.Subscriptions).Returns(mockSet.Object); // Arrange SubscriptionDBRepository repo = new SubscriptionDBRepository(mockContext.Object); // Act var result = repo.Get(3); // Assert Assert.Equal(result.TwitterId, 0); }