コード例 #1
0
        public void ShouldFindConversationsWhenUserIsNotFound()
        {
            //Arrange
            var domainService       = new Mock <ISocialUserService>();
            var conversationService = new Mock <IConversationAppService>();

            domainService.Setup(t => t.Find(1)).Returns <SocialUser>(null);
            SocialUserAppService socialUserAppService = new SocialUserAppService(domainService.Object,
                                                                                 conversationService.Object, null, null);
            //Act
            Action action = () => socialUserAppService.FindConversations(1);

            //Assert
            Assert.Throws <ExceptionWithCode>(action);
        }
コード例 #2
0
        public void ShouldFindConversations()
        {
            //Arrange
            var domainService       = new Mock <ISocialUserService>();
            var conversationService = new Mock <IConversationAppService>();

            domainService.Setup(t => t.Find(1)).Returns(new SocialUser {
                Id = 1
            });
            conversationService.Setup(t => t.Find(It.Is <ConversationSearchDto>(r => r.UserId == 1))).Returns(new List <ConversationDto>
            {
                new ConversationDto {
                    Id = 1
                }
            });
            SocialUserAppService socialUserAppService = new SocialUserAppService(domainService.Object,
                                                                                 conversationService.Object, null, null);
            //Act
            IList <ConversationDto> conversationDtos = socialUserAppService.FindConversations(1);

            //Assert
            Assert.True(conversationDtos.Any());
            Assert.Equal(1, conversationDtos.FirstOrDefault().Id);
        }