public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (NotificationsRequest)null)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest())); }
public MastodonClient(string domain) : base($"https://{domain}", AuthMode.OAuth2, RequestMode.FormUrlEncoded) { Domain = domain; BinaryParameters = new List <string> { "avatar", "header", "file" }; Account = new AccountsClient(this); Apps = new AppsClient(this); Auth = new AuthClient(this); Blocks = new BlocksClient(this); CustomEmojis = new CustomEmojisClient(this); DomainBlocks = new DomainBlocksClient(this); Endorsements = new EndorsementsClient(this); Favorites = new FavoritesClient(this); Filters = new FiltersClient(this); FollowRequests = new FollowRequestsClient(this); Follows = new FollowsClient(this); Instance = new InstanceClient(this); Lists = new ListsClient(this); Media = new MediaClient(this); Notifications = new NotificationsClient(this); Push = new PushClient(this); Reports = new ReportsClient(this); SearchV1 = new SearchV1Client(this); SearchV2 = new SearchV2Client(this); Statuses = new StatusesClient(this); Streaming = new StreamingClient(this); Suggestions = new SuggestionsClient(this); Timelines = new TimelinesClient(this); }
public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); var details = taskInstance.TriggerDetails as ToastNotificationActionTriggerDetail; if (details != null) { var arguments = details.Argument.Split('='); var notificationId = int.Parse(arguments[2]); WinSecureStorageBase.StoragePassword = "******"; //Octokit var client = new GitHubClient(new ProductHeaderValue("gitit")); if (CrossSecureStorage.Current.HasKey("OAuthToken")) { client.Credentials = new Credentials(CrossSecureStorage.Current.GetValue("OAuthToken")); var notificationsClient = new NotificationsClient(new ApiConnection(client.Connection)); await notificationsClient.MarkAsRead(notificationId); } } _deferral.Complete(); }
public MisskeyClient(Credential credential, HttpClientHandler innerHandler = null) : base(credential, new MisskeyAuthenticationHandler(innerHandler), RequestMode.Json) { BinaryParameters = new List <string> { "file" }; Aggregation = new AggregationClient(this); Ap = new ApClient(this); Admin = new AdminClient(this); App = new MisskeyAppClient(this); Auth = new AuthClient(this); Blocking = new BlockingClient(this); Charts = new ChartsClient(this); Drive = new DriveClient(this); Federation = new FederationClient(this); Following = new FollowingClient(this); Hashtags = new HashtagsClient(this); I = new IClient(this); Messaging = new MessagingClient(this); Mute = new MuteClient(this); My = new MyClient(this); Notes = new NotesClient(this); Notifications = new NotificationsClient(this); Streaming = new StreamingClient(this); Username = new UsernameClient(this); Users = new UsersClient(this); }
public MastodonClient(Credential credential, HttpClientHandler innerHandler = null) : base(credential, new OAuth2HttpClientHandler(innerHandler), RequestMode.FormUrlEncoded) { BinaryParameters = new List <string> { "avatar", "header", "file" }; Account = new AccountsClient(this); Apps = new AppsClient(this); Auth = new AuthClient(this); Blocks = new BlocksClient(this); Conversations = new ConversationsClient(this); CustomEmojis = new CustomEmojisClient(this); DomainBlocks = new DomainBlocksClient(this); Endorsements = new EndorsementsClient(this); Favorites = new FavoritesClient(this); Filters = new FiltersClient(this); FollowRequests = new FollowRequestsClient(this); Follows = new FollowsClient(this); Instance = new InstanceClient(this); Lists = new ListsClient(this); Media = new MediaClient(this); Notifications = new NotificationsClient(this); Push = new PushClient(this); Reports = new ReportsClient(this); ScheduledStatuses = new ScheduledStatusesClient(this); SearchV1 = new SearchV1Client(this); SearchV2 = new SearchV2Client(this); Statuses = new StatusesClient(this); Streaming = new StreamingClient(this); Suggestions = new SuggestionsClient(this); Timelines = new TimelinesClient(this); }
private async Task MarkAllNotificationsAsRead() { var notificationsClient = new NotificationsClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection)); await notificationsClient.MarkAsRead(); await Refresh(); }
public void Then_Expected_Methods_Are_Called() { NotificationsClient .Received(1) .SendEmailAsync(Arg.Is <string>(emailAddress => emailAddress == ToAddress), Arg.Is <string>(templateId => templateId == NotificationTemplate.TemplateId.ToString()), Arg.Is <Dictionary <string, dynamic> >(dict => dict.First().Key == "tlevel_name")); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.GetAllForCurrent((NotificationsRequest)null)); }
public async Task GetNotificationsMethod() { var notifications = await NotificationsClient.GetNotifications(); Assert.NotNull(notifications); Assert.NotNull(notifications.List); Assert.NotEmpty(notifications.List); }
/// <summary> /// Instantiate a new GitHub Activities API client. /// </summary> /// <param name="apiConnection">An API connection</param> public ActivitiesClient(IApiConnection apiConnection) : base(apiConnection) { Events = new EventsClient(apiConnection); Starring = new StarredClient(apiConnection); Watching = new WatchedClient(apiConnection); Feeds = new FeedsClient(apiConnection); Notifications = new NotificationsClient(apiConnection); }
/// <summary> /// Instantiate a new GitHub Activities API client. /// </summary> /// <param name="apiConnection">An API connection</param> public ActivitiesClient(IApiConnection apiConnection) : base(apiConnection) { Events = new EventsClient(apiConnection); Starring = new StarredClient(apiConnection); Watching = new WatchedClient(apiConnection); Feeds = new FeedsClient(apiConnection); Notifications = new NotificationsClient(apiConnection); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications/threads/1", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsRead(1); connection.Received().Patch(endpoint); }
public async Task RequestsCorrectUrl() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); await client.GetAllForRepository("banana", "split"); connection.Received().GetAll <Notification>(endpoint, Args.ApiOptions); }
private async Task MarkNotificationAsRead(Notification notification) { if (MarkedNotification == null) { return; } var notificationsClient = new NotificationsClient(new ApiConnection(GithubClientService.GetAuthorizedGithubClient().Connection)); await notificationsClient.MarkAsRead(int.Parse(MarkedNotification.Id)); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications/threads/1", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); client.Get(1); connection.Received().Get<Notification>(endpoint); }
public void RequestsCorrectUrl() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsReadForRepository("banana", "split"); connection.Received().Put(endpoint); }
public async Task RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); await client.GetAllForCurrent(); connection.Received().GetAll <Notification>(endpoint, Args.ApiOptions); }
public void RequestsCorrectUrlWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsReadForRepository(1); connection.Received().Put(endpoint); }
public async Task RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); await client.GetAllForCurrent(); connection.Received().GetAll<Notification>(endpoint, Args.ApiOptions); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.GetAllForCurrent(); connection.Received().GetAll <Notification>(endpoint); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsRead(); connection.Received().Put <object>(endpoint, Args.Object); }
public void RequestsCorrectUrl() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsReadForRepository("banana", "split"); connection.Received().Put(endpoint); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); client.MarkAsRead(); connection.Received().Put(endpoint); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications/threads/1/subscription", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); client.DeleteThreadSubscription(1); connection.Received().Delete(endpoint); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications/threads/1/subscription", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var data = new NewThreadSubscription(); client.SetThreadSubscription(1, data); connection.Received().Put <ThreadSubscription>(endpoint, data); }
public async Task RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; await client.GetAllForCurrent(notificationsRequest); connection.Received().GetAll<Notification>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public async Task RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; await client.GetAllForCurrent(notificationsRequest); connection.Received().GetAll <Notification>(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public async Task RequestsCorrectUrlApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForCurrent(options); connection.Received().GetAll<Notification>(endpoint, options); }
public async Task RequestsCorrectUrlWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", options); connection.Received().GetAll <Notification>(endpoint, options); }
public async Task RequestsCorrectUrlApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForCurrent(options); connection.Received().GetAll <Notification>(endpoint, options); }
public SIPSorceryNotificationClient(ActivityMessageDelegate logActivityMessage, string serverURL, string authid) { LogActivityMessage_External = logActivityMessage; m_address = Guid.NewGuid().ToString(); BasicHttpSecurityMode securitymode = (serverURL.StartsWith("https")) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; SIPSorcerySecurityHeader securityHeader = new SIPSorcerySecurityHeader(authid); PullNotificationHeader notificationHeader = new PullNotificationHeader(m_address); SIPSorceryCustomHeader sipSorceryHeader = new SIPSorceryCustomHeader(new List<MessageHeader>() { securityHeader, notificationHeader }); BasicHttpCustomHeaderBinding binding = new BasicHttpCustomHeaderBinding(sipSorceryHeader, securitymode); EndpointAddress address = new EndpointAddress(serverURL); m_notificationClient = new NotificationsClient(binding, address); m_notificationClient.IsAliveCompleted += IsAliveCompleted; m_notificationClient.GetPollPeriodCompleted += GetPollPeriodCompleted; m_notificationClient.SubscribeCompleted += SubscribeCompleted; m_notificationClient.GetNotificationsCompleted += GetNotificationsCompleted; }
public void RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForCurrent(notificationsRequest, options); connection.Received().GetAll<Notification>(endpoint, Arg.Is<IDictionary<string, string>>(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init(); Notifications = new NotificationsClient(); // registers for push for iOS8 var settings = UIUserNotificationSettings.GetSettingsForTypes( UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, new NSSet()); UIApplication.SharedApplication.RegisterUserNotificationSettings(settings); UIApplication.SharedApplication.RegisterForRemoteNotifications(); LoadApplication(new App()); return(base.FinishedLaunching(app, options)); }
public SIPSorceryNotificationClient(ActivityMessageDelegate logActivityMessage, string serverURL, string apiKey) { LogActivityMessage_External = logActivityMessage; m_address = Guid.NewGuid().ToString(); BasicHttpSecurityMode securitymode = (serverURL.StartsWith("https")) ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None; SIPSorcerySecurityHeader securityHeader = new SIPSorcerySecurityHeader(apiKey); PullNotificationHeader notificationHeader = new PullNotificationHeader(m_address); SIPSorceryCustomHeader sipSorceryHeader = new SIPSorceryCustomHeader(new List <MessageHeader>() { securityHeader, notificationHeader }); BasicHttpCustomHeaderBinding binding = new BasicHttpCustomHeaderBinding(sipSorceryHeader, securitymode); EndpointAddress address = new EndpointAddress(serverURL); m_notificationClient = new NotificationsClient(binding, address); m_notificationClient.IsAliveCompleted += IsAliveCompleted; m_notificationClient.GetPollPeriodCompleted += GetPollPeriodCompleted; m_notificationClient.SubscribeCompleted += SubscribeCompleted; m_notificationClient.GetNotificationsCompleted += GetNotificationsCompleted; }
public void RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAllForCurrent(notificationsRequest, options); connection.Received().GetAll <Notification>(endpoint, Arg.Is <IDictionary <string, string> >(d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
/// <summary> /// Initializes a new instance of the <see cref="GoodreadsClient"/> class. /// Use this constructor if you already have OAuth permissions for the user. /// </summary> /// <param name="apiKey">Your Goodreads API key.</param> /// <param name="apiSecret">Your Goodreads API secret.</param> /// <param name="accessToken">The user's OAuth access token.</param> /// <param name="accessSecret">The user's OAuth access secret.</param> public GoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret) { var client = new RestClient(new Uri(GoodreadsUrl)) { UserAgent = "goodreads-dotnet" }; client.AddDefaultParameter("key", apiKey, ParameterType.QueryString); client.AddDefaultParameter("format", "xml", ParameterType.QueryString); var apiCredentials = new ApiCredentials(client, apiKey, apiSecret, accessToken, accessSecret); // Setup the OAuth authenticator if they have passed on the appropriate tokens if (!string.IsNullOrWhiteSpace(accessToken) && !string.IsNullOrWhiteSpace(accessSecret)) { client.Authenticator = OAuth1Authenticator.ForProtectedResource( apiKey, apiSecret, accessToken, accessSecret); } Connection = new Connection(client, apiCredentials); Authors = new AuthorsClient(Connection); Books = new BooksClient(Connection); Shelves = new ShelvesClient(Connection); Users = new UsersClient(Connection); Reviews = new ReviewsClient(Connection); Series = new SeriesClient(Connection); AuthorsFollowing = new AuthorsFollowingClient(Connection); Events = new EventsClient(Connection); Followers = new FollowersClient(Connection); Friends = new FriendsClient(Connection); Notifications = new NotificationsClient(Connection); Groups = new GroupClient(Connection); Quotes = new QuotesClient(Connection); UserStatuses = new UserStatusesClient(Connection); Updates = new UpdatesClient(Connection); Recommendations = new RecommendationsClient(Connection); ReadStatuses = new ReadStatusesClient(Connection); }
public async Task RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For <IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", notificationsRequest, options); connection.Received().GetAll <Notification>(endpoint, Arg.Is <Dictionary <string, string> >( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name", new MarkAsReadRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null, new MarkAsReadRequest())); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository("owner", "name", null)); await Assert.ThrowsAsync <ArgumentNullException>(() => client.MarkAsReadForRepository(1, null)); await Assert.ThrowsAsync <ArgumentException>(() => client.MarkAsReadForRepository("", "name")); await Assert.ThrowsAsync <ArgumentException>(() => client.MarkAsReadForRepository("owner", "")); await Assert.ThrowsAsync <ArgumentException>(() => client.MarkAsReadForRepository("", "name", new MarkAsReadRequest())); await Assert.ThrowsAsync <ArgumentException>(() => client.MarkAsReadForRepository("owner", "", new MarkAsReadRequest())); }
public async Task RequestsCorrectUrl() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); await client.GetAllForRepository("banana", "split"); connection.Received().GetAll<Notification>(endpoint, Args.ApiOptions); }
public void RequestsCorrectUrlNotificationRequest() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; client.GetAllForRepository("banana", "split", notificationsRequest); connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), Args.ApiOptions); }
public async Task RequestsCorrectUrlWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", options); connection.Received().GetAll<Notification>(endpoint, options); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (NotificationsRequest)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", new NotificationsRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, new NotificationsRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", new NotificationsRequest(), null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (ApiOptions)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, (NotificationsRequest)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, null, ApiOptions.None)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(1, new NotificationsRequest(), null)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", new NotificationsRequest(), ApiOptions.None)); await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", new NotificationsRequest(), ApiOptions.None)); }
public async Task RequestsCorrectUrlNotificationRequestWithApiOptions() { var endpoint = new Uri("repos/banana/split/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var notificationsRequest = new NotificationsRequest { All = true }; var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; await client.GetAllForRepository("banana", "split", notificationsRequest, options); connection.Received().GetAll<Notification>(endpoint, Arg.Is<Dictionary<string, string>>( d => d.Count == 2 && d["all"] == "true" && d["participating"] == "false"), options); }
public void RequestsCorrectUrlParameterizedWithRepositoryId() { var endpoint = new Uri("repositories/1/notifications", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var markAsReadRequest = new MarkAsReadRequest(); client.MarkAsReadForRepository(1, markAsReadRequest); connection.Received().Put<object>(endpoint, markAsReadRequest); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository(null, "name", new MarkAsReadRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", null, new MarkAsReadRequest())); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository("owner", "name", null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.MarkAsReadForRepository(1, null)); await Assert.ThrowsAsync<ArgumentException>(() => client.MarkAsReadForRepository("", "name")); await Assert.ThrowsAsync<ArgumentException>(() => client.MarkAsReadForRepository("owner", "")); await Assert.ThrowsAsync<ArgumentException>(() => client.MarkAsReadForRepository("", "name", new MarkAsReadRequest())); await Assert.ThrowsAsync<ArgumentException>(() => client.MarkAsReadForRepository("owner", "", new MarkAsReadRequest())); }
public void RequestsCorrectUrl() { var endpoint = new Uri("notifications/threads/1/subscription", UriKind.Relative); var connection = Substitute.For<IApiConnection>(); var client = new NotificationsClient(connection); var data = new NewThreadSubscription(); client.SetThreadSubscription(1, data); connection.Received().Put<ThreadSubscription>(endpoint, data); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null)); await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((NotificationsRequest)null)); }
public async Task EnsuresNonNullArguments() { var client = new NotificationsClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => client.SetThreadSubscription(1, null)); }