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
add-type @" | |
using System.Net; | |
using System.Security.Cryptography.X509Certificates; | |
public class TrustAllCertsPolicy : ICertificatePolicy { | |
public bool CheckValidationResult( | |
ServicePoint srvPoint, X509Certificate certificate, | |
WebRequest request, int certificateProblem) { | |
return true; | |
} | |
} |
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 static class DynamicExtensions | |
{ | |
public static dynamic ToDynamic(this object value) | |
{ | |
IDictionary<string, object> expando = new ExpandoObject(); | |
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value.GetType())) | |
expando.Add(property.Name, property.GetValue(value)); | |
return expando as ExpandoObject; |
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 static Task<HttpResponseMessage> GetAsync | |
(this HttpClient httpClient, string uri, Action<HttpRequestMessage> preAction) | |
{ | |
var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri); | |
preAction(httpRequestMessage); | |
return httpClient.SendAsync(httpRequestMessage); | |
} |
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 static string CleanFileName(string fileName) | |
{ | |
return Path.GetInvalidFileNameChars().Aggregate(fileName, (current, c) => current.Replace(c.ToString(), string.Empty)); | |
} |
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 static int Main(string[] args) => | |
Try | |
.Action(() => 0) | |
.WithCatch<Exception>(ex => 1}) | |
.Finally(CleanUpMethod); |
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
#r @"./packages/fsharp-data/netstandard2.0/Fsharp.Data.dll" | |
#r @"./packages/newtonsoft.json/netstandard2.0/Newtonsoft.Json.dll" | |
open System | |
open FSharp.Data | |
open Newtonsoft.Json.Linq | |
let timeSeriesUrl = "https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=%s&outputsize=full&apikey=A3U8E3F7N3A85K86" | |
type TimeSeries = FSharp.Data.JsonProvider<"""{ | |
"2. high": "123.4567", |
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
private TestServer CreateTestServer() => | |
new TestServer(new WebHostBuilder() | |
.UseStartup<FakeStartup>()); | |
class FakeStartup | |
{ | |
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
app.Run(async ctx => | |
{ |
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
# Mac | |
../dotcover/dotCover.sh cover --output=./bin/<project coverage>.html --reportType=HTML --TargetExecutable=/usr/local/share/dotnet/dotnet -- test ./<project>/<project>.UnitTests/ |
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
abstract class SpecsForController<TSut, TResult> where TSut : ControllerBase where TResult : ActionResult | |
{ | |
private readonly NSubstituteMockingKernel kernel = new NSubstituteMockingKernel(); | |
private TSut Subject { get; set; } | |
protected TResult Result { get; private set; } | |
protected HttpContextBase HttpContext => Subject.ControllerContext.HttpContext; | |
protected virtual void Arrange(ControllerContext context) { } | |
protected abstract Expression<Action<TSut>> Act { get; } | |
protected TService ResolveDependency<TService>() => kernel.Get<TService>(); | |
protected void RegisterDependency<TDependency>(TDependency dependency) |
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
open System | |
open System.Text | |
open FSharp.Data | |
open FSharp.Json | |
let (username, password) = ("username", "password") | |
let repositoryRootUrl = "https://api.bitbucket.org/2.0/repositories/team_workspace" | |
let repositories = [ "RepoA"; "RepoB" ] | |
let lookBack = DateTime.Now.AddDays(-1.0) | |
let maxOutdatedToTake = 10 |