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); } }
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(); }
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); } } }
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"); } }
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); } }