public async Task RunsConfiguredAppWithAcceptsOverride() { var httpClient = Substitute.For<IHttpClient>(); IResponse response = new Response(); httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response)); var connection = new Connection(new ProductHeaderValue("OctokitTests"), _exampleUri, Substitute.For<ICredentialStore>(), httpClient, Substitute.For<IJsonSerializer>()); await connection.Patch<string>(new Uri("endpoint", UriKind.Relative), new object(), "custom/accepts"); httpClient.Received(1).Send(Arg.Is<IRequest>(req => req.Headers["Accept"] == "custom/accepts"), Args.CancellationToken); }
public async Task RunsConfiguredAppWithAppropriateEnv() { string data = SimpleJson.SerializeObject(new object()); var httpClient = Substitute.For<IHttpClient>(); IResponse response = new Response(); httpClient.Send(Args.Request, Args.CancellationToken).Returns(Task.FromResult(response)); var connection = new Connection(new ProductHeaderValue("OctokitTests"), _exampleUri, Substitute.For<ICredentialStore>(), httpClient, Substitute.For<IJsonSerializer>()); await connection.Patch<string>(new Uri("endpoint", UriKind.Relative), new object()); httpClient.Received(1).Send(Arg.Is<IRequest>(req => req.BaseAddress == _exampleUri && (string)req.Body == data && req.Method == HttpVerb.Patch && req.ContentType == "application/x-www-form-urlencoded" && req.Endpoint == new Uri("endpoint", UriKind.Relative)), Args.CancellationToken); }