This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
namespace SimpleHttpClient | |
{ | |
class Program | |
{ | |
private static Uri url = new Uri("http://bing.com/"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringExtensionsSpecifications | |
{ | |
[Scenario] | |
[Example("Given", StepType.Given)] | |
[Example("When", StepType.When)] | |
[Example("Then", StepType.Then)] | |
[Example("But", StepType.But)] | |
[Example("And", StepType.And)] | |
public void GetStepType(string clause, StepType expected, StepType actual) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Scenario] | |
public void RetrievingIssues(IEnumerable<Issue> issues, Mock<IIssueStore> issueStore ) | |
{ | |
var mockIssueStore = new Mock<IIssueStore>(); | |
var fakeIssues = GetFakeIssues(); | |
var controller = new IssueController(mockIssueStore.Object); | |
"Given existing issues". | |
f(() => mockIssueStore.Setup(i => i.FindAsync()).Returns(Task.FromResult(fakeIssues))); | |
"When a GET request is made for all issues". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var client = new HttpClient(); | |
var runscopeLink = new RunScopeLink() { | |
Target = new Uri("https://api.github.com"), | |
BucketKey = "bucket_key" | |
}; | |
var response = client.SendAsync(runscopeLink.CreateRequest()).Response; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var runscopeHandler = new RunscopeMessageHandler("bucketKey", new HttpClientHandler()); | |
var httpClient = new HttpClient(runscopeHandler); | |
var response = await httpClient.GetAsync("https://api.github.com"); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ask the server for a password challenge string | |
var requestId = CryptographicBuffer.EncodeToHexString(CryptographicBuffer.GenerateRandom(4)); | |
var challengeResponse = await _httpClient.GetAsync(_clientBaseUrl + "GetPasswordChallenge?requestId=" + requestId); | |
challengeResponse.EnsureSuccessStatusCode(); | |
var challengeEncoded = await challengeResponse.Content.ReadAsAsync<string>(); | |
var challengeBuffer = CryptographicBuffer.DecodeFromHexString(challengeEncoded); | |
// Use HMAC_SHA512 hash to encode the challenge string using the password being authenticated as the key. | |
var provider = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha512); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.Routes.MapHttpRoute( | |
name: "TreeApi", | |
routeTemplate: "tree/{*path}", | |
defaults: null, | |
constraints: null, | |
handler: new ApiRouter("", new Uri("http://localhost:64921/tree")).To<FooController>()); | |
config.Routes.MapHttpRoute( | |
name: "DefaultApi", | |
routeTemplate: "api/{controller}/{id}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FORM method="POST" action="http://example.com/whatever-I-dont-care"> | |
<INPUT type="text" name="value1" value="default1"/> | |
<INPUT type="text" name="value2" value="default2"/> | |
<FORM> | |
<LINK rel="http://tavis.ca/rels/form" method="POST" href="http://example.com/whatever-I-dont-care"> | |
<INPUT type="text" name="value1" value="default1"/> | |
<INPUT type="text" name="value2" value="default2"/> | |
<LINK> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CollectionJsonContent : HttpContent | |
{ | |
private readonly MemoryStream _memoryStream = new MemoryStream(); | |
public CollectionJsonContent(Collection collection) | |
{ | |
var serializerSettings = new JsonSerializerSettings | |
{ | |
NullValueHandling = NullValueHandling.Ignore, | |
Formatting = Newtonsoft.Json.Formatting.Indented, | |
ContractResolver = new CamelCasePropertyNamesContractResolver() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Web.Http; | |
using System.Web.Http.Owin; | |
using Microsoft.Owin; | |
using Microsoft.Owin.BuilderProperties; | |
using Microsoft.Owin.Host.HttpListener; |