private static Mock <IRepository <Entities.Message> > GetMessageProvider() { var mockMessageRepository = new Mock <IRepository <Entities.Message> >(); var msg = new Entities.Message { Id = 1, Text = "Hello world!" }; mockMessageRepository.Setup(m => m.GetAll()).Returns(new List <Entities.Message> { msg }); return(mockMessageRepository); }
public void GetAll_ShouldReturnData() { //Arrange var mockMessageRepository = new Mock <IRepository <Entities.Message> >(); var msg = new Entities.Message { Id = 1, Text = "Hello world!" }; mockMessageRepository.Setup(m => m.GetAll()).Returns(new List <Entities.Message> { msg }); //Act var sut = new MessagesProvider(mockMessageRepository.Object); var result = sut.GetAll(); //Assert Assert.True(result.Any()); }