Exemple #1
0
        public void ShouldUpdateAccountWhenSocialAccountIsNotFound()
        {
            //Arrange
            var socialAccountService = new Mock <ISocialAccountService>();

            socialAccountService.Setup(t => t.FindAccount(1, SocialUserSource.Twitter)).Returns <SocialAccount>(null);
            TwitterAccountAppService TwitterAccountAppService = new TwitterAccountAppService(socialAccountService.Object, null);
            //Act
            Action action = () => TwitterAccountAppService.UpdateAccount(1, new UpdateTwitterAccountDto {
                IfEnable = true
            });

            //Assert
            Assert.Throws <ExceptionWithCode>(action);
        }
Exemple #2
0
        public void ShouldUpdateAccount()
        {
            //Arrange
            var socialAccountService = new Mock <ISocialAccountService>();

            socialAccountService.Setup(t => t.FindAccount(1, SocialUserSource.Twitter)).Returns(
                new SocialAccount {
                Id = 1
            });
            TwitterAccountAppService TwitterAccountAppService = new TwitterAccountAppService(socialAccountService.Object, null);
            //Act
            TwitterAccountDto twitterAccountDto = TwitterAccountAppService.UpdateAccount(1, new UpdateTwitterAccountDto {
                IfEnable = true
            });

            //Assert
            Assert.NotNull(twitterAccountDto);
            socialAccountService.Verify(t => t.Update(It.Is <SocialAccount>(r => r.Id == 1 && r.IfEnable == true)));
            Assert.Equal(1, twitterAccountDto.Id);
            Assert.Equal(true, twitterAccountDto.IfEnable);
        }