Skip to content

Instantly share code, notes, and snippets.

<Project Sdk="Microsoft.NET.Sdk">
<!-- Add the following SDK reference 👇 -->
<Sdk Name="Aspire.AppHost.Sdk" Version="9.0.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>360e1e8e-629b-4b91-8be6-3587b33fa61d</UserSecretsId>
[Fact]
public void WhenIAddTwoRandomNumbersTheResultShouldNotDependOnParameterOrder_2()
{
var config = Config.Default.WithMaxTest(200);
var addingTwoRandomNumbers = (int x, int y) => Add(x, y) == Add(y, x);
Prop.ForAll(new Func<int, int, bool>(addingTwoRandomNumbers))
.Check(config);
}
private static Gen<Reservation> GenerateReservation =>
from d in ArbMap.Default.GeneratorFor<DateTime>()
from e in ArbMap.Default.GeneratorFor<NonWhiteSpaceString>()
from n in ArbMap.Default.GeneratorFor<NonWhiteSpaceString>()
from q in ArbMap.Default.GeneratorFor<PositiveInt>()
select new Reservation
{
Date = d,
Email = e.Item,
Name = n.Item,
using FsCheck.Xunit;
using FsCheck;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Add this namespace to add the Throws method to the Prop
using FsCheck.FSharp;
using FsCheck;
using FsCheck.Fluent;
app.MapScalarApiReference(options => {
options
.WithTitle("Example API");
});
builder.Services.AddOpenApi(options => {
options.AddDocumentTransformer<AuthenticationSchemeTransformer>();
});
internal sealed class AuthenticationSchemeTransformer(Microsoft.AspNetCore.Authentication.IAuthenticationSchemeProvider authenticationSchemeProvider) : IOpenApiDocumentTransformer
{
public async Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken)
{
var authenticationSchemes = await authenticationSchemeProvider.GetAllSchemesAsync();
if (authenticationSchemes.Any(authScheme => authScheme.Name == "API Key"))
{
document.Components ??= new OpenApiComponents();
builder.Services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "API Key";
options.DefaultChallengeScheme = "API Key";
})
.AddScheme<IAMApiKeyAuthenticationOptions, IAMApiKeyAuthenticationHandler>("API Key", options);
Get-WinEvent -FilterHashtable @{
'LogName' = 'Microsoft-Windows-TaskScheduler/Operational'
'ID' = 200, 201
} | Group-Object ActivityID | ForEach-Object {
$start = $_.Group |
Where-Object { $_.Id -eq 200 } |
Select-Object -Expand TimeCreated -First 1
$end = $_.Group |
Where-Object { $_.Id -eq 201 } |
Select-Object -Expand TimeCreated -First 1