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

            socialAccountService.Setup(t => t.FindAccount(1, SocialUserSource.Facebook)).Returns <SocialAccount>(null);
            FacebookAccountAppService conversationMessageAppService = new FacebookAccountAppService(socialAccountService.Object, null);

            //Act
            Action action = () => conversationMessageAppService.DeletePageAsync(1).Start();

            //Assert
            Assert.NotNull(conversationMessageAppService.DeletePageAsync(1).Exception);
            // Assert.Throws<ExceptionWithCode>(action);
        }
Beispiel #2
0
        public void ShouldDeletePageAsync()
        {
            //Arrange
            var socialAccountService = new Mock <ISocialAccountService>();
            var socialUserService    = new Mock <ISocialUserService>();
            var fbClient             = new Mock <IFbClient>();

            socialAccountService.Setup(t => t.FindAccount(1, SocialUserSource.Facebook)).Returns(new SocialAccount {
                Id = 1, SocialUser = new SocialUser {
                    OriginalId = "1"
                }, Token = "123"
            });
            FacebookAccountAppService conversationMessageAppService = new FacebookAccountAppService(socialAccountService.Object, fbClient.Object);

            //Act
            conversationMessageAppService.DeletePageAsync(1);
            //Assert
            socialAccountService.Verify(t => t.DeleteAsync(It.Is <SocialAccount>(r => r.Id == 1)));
            fbClient.Verify(t => t.UnSubscribeApp(It.Is <string>(s => s == "1"), It.Is <string>(k => k == "123")));
        }