public void GetPost_CreatesChatPostCorrectly() { var baseUri = new Uri("http://localhost"); var thread = new Thread { Order = new[] { POST_ID, ROOT_ID }, Posts = new Dictionary <string, Post>() }; thread.Posts[POST_ID] = new Post { Id = POST_ID, RootId = ROOT_ID }; thread.Posts[ROOT_ID] = new Post { Id = ROOT_ID, RootId = string.Empty }; var restService = new Mock <IRestService>(); var chatPost = new Mock <IChatPost>(); var channelFactory = new Mock <IChatPostFactory>(); channelFactory.Setup( x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_GUID, thread.Posts[POST_ID])) .Returns(chatPost.Object); restService.Setup(x => x.GetPostById(baseUri, TOKEN, TEAM_GUID, POST_ID)).Returns(thread); var sut = new SessionImpl(restService.Object, baseUri, TOKEN, USER_ID, TEAM_GUID, Mock.Of <IChatChannelFactory>(), channelFactory.Object); var result = sut.GetPost(POST_ID); Assert.That(result, Is.EqualTo(chatPost.Object)); }
public void GetPost_CreatesChatPostCorrectly() { var baseUri = new Uri("http://localhost"); var post = new Post { Id = POST_ID, RootId = ROOT_ID }; var restService = new Mock <IRestService>(); var chatPost = new Mock <IChatPost>(); var channelFactory = new Mock <IChatPostFactory>(); channelFactory.Setup( x => x.NewInstance(restService.Object, baseUri, TOKEN, TEAM_ID, post)) .Returns(chatPost.Object); restService.Setup(x => x.GetPostById(baseUri, TOKEN, POST_ID)).Returns(post); var sut = new SessionImpl(restService.Object, baseUri, TOKEN, TEAM_ID, Mock.Of <IChatChannelFactory>(), channelFactory.Object); var result = sut.GetPost(POST_ID); result.ShouldBeEquivalentTo(chatPost.Object); }