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
board = [ | |
[None, None, None], | |
[None, None, None], | |
[None, None, None] | |
] | |
def available_goes(): | |
return len([item for item in [x for sublist in [board[0], board[1], board[2]] for x in sublist] if item is None]) > 0 | |
def set_position(player, x, y): |
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
static class TypeExtensions | |
{ | |
public static IEnumerable<Type> GetInstanceTypesImplementing<T>( | |
this Assembly assembly, params Assembly[] assemblies) | |
{ | |
var serviceType = typeof(T); | |
return assemblies.Union(new [] { assembly }).SelectMany(x => x.GetTypes()) | |
.Where( x => x.IsClass && !x.IsAbstract && serviceType.IsAssignableFrom( x ) ); | |
} |
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
logger.LogInformation($"We can now do this {someCode}"); | |
logger.LogInformation($"And this {1 + 1:Calculated}"); | |
logger.LogInformation($"And also this {() => ExpensiveMethodCall(TimeSpan.FromSeconds(1)):Expensive}"); | |
logger.LogInformation($"And not worry about {UnsafeMethodCall:Unsafe}"); | |
logger.LogTrace($"And not have to check if the log level is enabled {() => ExpensiveMethodCall(TimeSpan.FromSeconds(10)):Expensive}"); |
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
class BufferedTextWriterSink : ILogEventSink, IDisposable | |
{ | |
private readonly LogEventLevel? standardErrorFromLevel; | |
private readonly ITextFormatter formatter; | |
private readonly object _syncRoot = new(); | |
private readonly TextWriter standardWriter; | |
private readonly TextWriter errorWriter; | |
private readonly ConcurrentBag<LogEvent> logEvents = new(); |
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
/// <summary> | |
/// <see cref="DelegatingHandler"/> that can be used to capture the actual outbound request and the returned | |
/// response. These are logged by default to the console but can also be routed to an action. This can be useful | |
/// for tests that use a <see cref="HttpClient"/> to call a fake service. | |
/// </summary> | |
/// <example> | |
/// new HttpClient(new LoggingDelegatingHandler(new HttpClientHandler())); | |
/// </example> | |
public class LoggingDelegatingHandler : DelegatingHandler | |
{ |
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 |
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
# 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
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
#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", |
NewerOlder