Beispiel #1
0
        public void ShouldGetPendingAddPagesAsync()
        {
            //Arrange
            var socialAccountService = new Mock <ISocialAccountService>();
            var socialUserService    = new Mock <ISocialUserService>();
            var fbClient             = new Mock <IFbClient>();

            fbClient.Setup(t => t.GetUserToken("a", "b")).Returns("1");
            fbClient.Setup(t => t.GetMe("1")).ReturnsAsync(new FbUser {
                name = "a", pic = "123"
            });
            fbClient.Setup(t => t.GetPages("1")).ReturnsAsync(new List <FbPage>
            {
                new FbPage {
                    Id = "1", Name = "a", Category = "b", AccessToken = "d", Link = "e"
                }
            });
            fbClient.Setup(t => t.GetUserInfo("1", "1")).ReturnsAsync(new FbUser {
                pic = "c"
            });
            socialAccountService.Setup(t => t.FindAll()).Returns(new List <SocialAccount>
            {
                new SocialAccount {
                    Id = 1, SocialUser = new SocialUser {
                        OriginalId = "1", Source = SocialUserSource.Facebook
                    }
                }
            }.AsQueryable());
            FacebookAccountAppService conversationMessageAppService = new FacebookAccountAppService(socialAccountService.Object, fbClient.Object);

            //Act
            Task <PendingAddFacebookPagesDto> pendingAddFacebookPagesDto = conversationMessageAppService.GetPendingAddPagesAsync("a", "b");

            //Assert
            Assert.NotNull(pendingAddFacebookPagesDto);
            Assert.Equal("a", pendingAddFacebookPagesDto.Result.SignInAs.Name);
            Assert.Equal("123", pendingAddFacebookPagesDto.Result.SignInAs.Avatar);
            Assert.Equal("1", pendingAddFacebookPagesDto.Result.Pages.FirstOrDefault().FacebookId);
            Assert.Equal(true, pendingAddFacebookPagesDto.Result.Pages.FirstOrDefault().IsAdded);
        }
Beispiel #2
0
        public void ShouldUpdatePage()
        {
            //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
            FacebookPageDto facebookPageDto = conversationMessageAppService.UpdatePage(1, new UpdateFacebookPageDto {
            });

            //Assert
            Assert.NotNull(facebookPageDto);
            socialAccountService.Verify(t => t.Update(It.Is <SocialAccount>(r => r.Id == 1)));
        }