public void GetConversation_ConversationIdPassed_CorrectConversationReturned() { //Arrange var context = new Mock <DatabaseContext>(); var dbSetMock = new Mock <DbSet <Conversation> >(); dbSetMock.As <IQueryable <Conversation> >().Setup(m => m.Provider).Returns(conversationList.Provider); dbSetMock.As <IQueryable <Conversation> >().Setup(m => m.Expression).Returns(conversationList.Expression); dbSetMock.As <IQueryable <Conversation> >().Setup(m => m.ElementType).Returns(conversationList.ElementType); dbSetMock.As <IQueryable <Conversation> >().Setup(m => m.GetEnumerator()).Returns(conversationList.GetEnumerator()); context.Setup(x => x.Conversations).Returns(dbSetMock.Object); var repository = new ConversationRepository(context.Object); //Act var conversation = repository.GetConversation(23); //Assert Assert.IsTrue(conversation.ConversationID == 23); }