コード例 #1
0
        public async Task DeAuthorize_SuccessfullDeAuthorizationIntegrationDeleted_UserIntegrationIsNull()
        {
            using (var unitOfWork = new FakeBrothershipUnitOfWork())
            {
                const int    userId    = 1;
                const string validCode = "ValidCode";

                unitOfWork.UserIntegrations.Add(new UserIntegration
                {
                    UserID            = userId,
                    ChannelId         = "ChannelId",
                    RefreshToken      = "ValidCode",
                    Token             = "Token",
                    IntegrationTypeID = (int)IntegrationType.IntegrationTypes.Youtube,
                });
                unitOfWork.Commit();


                using (var youtubeInegration = new YoutubeIntegration(unitOfWork,
                                                                      new YoutubeAuthClientFake(validCode),
                                                                      new YoutubeDataClientFake()))
                {
                    await youtubeInegration.DeAuthorize(userId);
                }

                var userInegration = unitOfWork.UserIntegrations.GetById(userId, (int)IntegrationType.IntegrationTypes.Youtube);
                Assert.IsNull(userInegration);
            }
        }
コード例 #2
0
        public async Task DeAuthorize_UnSuccessfullAuthorizationThrowException_ExceptionEqualHttpException()
        {
            using (var unitOfWork = new FakeBrothershipUnitOfWork())
            {
                const int    userId    = 1;
                const string validCode = "ValidCode";

                unitOfWork.UserIntegrations.Add(new UserIntegration
                {
                    UserID            = userId,
                    ChannelId         = "ChannelId",
                    RefreshToken      = "InvalidCode",
                    Token             = "Token",
                    IntegrationTypeID = (int)IntegrationType.IntegrationTypes.Youtube,
                });
                unitOfWork.Commit();


                using (var youtubeInegration = new YoutubeIntegration(unitOfWork,
                                                                      new YoutubeAuthClientFake(validCode),
                                                                      new YoutubeDataClientFake()))
                {
                    await youtubeInegration.DeAuthorize(userId);
                }
            }
        }