コード例 #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 Authorize_UnSuccessfullAuthorizationIntegrationNotAdded_UserIntegrationIsNull()
        {
            using (var unitOfWork = new FakeBrothershipUnitOfWork())
            {
                const int    userId    = 1;
                const string validCode = "ValidCode";

                using (var youtubeInegration = new YoutubeIntegration(unitOfWork,
                                                                      new YoutubeAuthClientFake("InvalidCode"),
                                                                      new YoutubeDataClientFake()))
                {
                    try
                    {
                        await youtubeInegration.Authorize(userId, validCode);
                    }
                    catch (Exception)
                    {
                        var userInegration = unitOfWork.UserIntegrations.GetById(userId, (int)IntegrationType.IntegrationTypes.Youtube);
                        Assert.IsNull(userInegration);
                        return;
                    }
                }
            }
            Assert.Fail();
        }
コード例 #3
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);
                }
            }
        }
コード例 #4
0
        public async Task Authorize_UnSuccessfullThrowsException_ExceptionEqualHTTPException()
        {
            const int    userId    = 1;
            const string validCode = "ValidCode";

            using (var youtubeInegration = new YoutubeIntegration(new FakeBrothershipUnitOfWork(),
                                                                  new YoutubeAuthClientFake(validCode),
                                                                  new YoutubeDataClientFake()))
            {
                await youtubeInegration.Authorize(userId, "InvalidCode");
            }
        }
コード例 #5
0
        public async Task Authorize_SuccessfullAuthorizationIntegrationAdded_UserIntegrationNotNull()
        {
            using (var unitOfWork = new FakeBrothershipUnitOfWork())
            {
                const int    userId    = 1;
                const string validCode = "ValidCode";

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

                var userInegration = unitOfWork.UserIntegrations.GetById(userId, (int)IntegrationType.IntegrationTypes.Youtube);
                Assert.IsNotNull(userInegration);
            }
        }