public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For<IApiConnection>()); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GetLatest(null, "name")); await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.GetLatest("", "name")); await Assert.ThrowsAsync<ArgumentNullException>(() => releasesClient.GetLatest("owner", null)); await Assert.ThrowsAsync<ArgumentException>(() => releasesClient.GetLatest("owner", "")); }
public async Task EnsuresNonNullArguments() { var releasesClient = new ReleasesClient(Substitute.For <IApiConnection>()); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.GetLatest(null, "name")); await Assert.ThrowsAsync <ArgumentException>(() => releasesClient.GetLatest("", "name")); await Assert.ThrowsAsync <ArgumentNullException>(() => releasesClient.GetLatest("owner", null)); await Assert.ThrowsAsync <ArgumentException>(() => releasesClient.GetLatest("owner", "")); }
public async Task RequestsTheCorrectUrl() { var connection = Substitute.For <IApiConnection>(); var client = new ReleasesClient(connection); await client.GetLatest("fake", "repo"); connection.Received().Get <Release>(Arg.Is <Uri>(u => u.ToString() == "repos/fake/repo/releases/latest")); }
public void RequestsTheCorrectUrl() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); client.GetLatest("fake", "repo"); connection.Received().Get<Release>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/releases/latest")); }
/// <summary> /// Gets the latest release. /// </summary> private static async Task<Release> GetLatest() { if (_release == null) { ReleasesClient releases = new ReleasesClient(new ApiConnection(new Connection(new ProductHeaderValue("DiscordPresenceUI")))); _release = await releases.GetLatest("hawezo", "DiscordPresenceUI"); } return _release; }
public async Task RequestsTheCorrectUrlWithRepositoryId() { var connection = Substitute.For<IApiConnection>(); var client = new ReleasesClient(connection); await client.GetLatest(1); connection.Received().Get<Release>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/releases/latest")); }