Skip to content

Instantly share code, notes, and snippets.

View jamesmcroft's full-sized avatar
👨‍💻
Coding From Anywhere

James Croft jamesmcroft

👨‍💻
Coding From Anywhere
View GitHub Profile
@jamesmcroft
jamesmcroft / logprobs.ts
Created April 24, 2024 14:10
Example of how to include the logprobs and top_logprobs properties in an Azure OpenAI request using the JavaScript SDK
const optionExtras = {
logprobs: true,
top_logprobs: 3,
};
const result = await client.getChatCompletions(
deploymentId,
[
{
role: "system",
@jamesmcroft
jamesmcroft / test-example-pipelines-simple.yml
Created September 9, 2020 14:08
A snippet of a pipeline example for running tests and generating cobertura reports
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
projects: '**/*[Tt]ests*.csproj'
@jamesmcroft
jamesmcroft / azure-pipelines.yml
Last active November 2, 2023 11:02
Example complete Azure DevOps CI pipeline with test projects
name: $(Major).$(Minor).$(Year:yy)$(DayOfYear).$(Rev:r)
trigger:
branches:
include:
- main
paths:
include:
- src/*
- build/*
@jamesmcroft
jamesmcroft / coverage-example-pipelines.yml
Last active September 9, 2020 14:07
A snippet of a pipelines YAML showing the ReportGenerator tool in use
- task: reportgenerator@4
inputs:
reports: '$(Build.SourcesDirectory)/**/*.cobertura.xml'
targetdir: '$(Build.SourcesDirectory)/CoverageResults'
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CoverageResults/Cobertura.xml'
@jamesmcroft
jamesmcroft / test-example-pipelines.yml
Last active September 9, 2020 14:07
A snippet of the pipelines YAML for running tests and generated coverage
- task: DotNetCoreCLI@2
displayName: 'Run unit tests'
inputs:
command: 'test'
arguments: '/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
projects: '**/*UnitTests*.csproj'
testRunTitle: 'Unit Tests'
- task: DotNetCoreCLI@2
displayName: 'Run functional tests'
@jamesmcroft
jamesmcroft / MyProject.UnitTests.csproj
Created July 4, 2020 13:57
A sample test project file with coverlet installed
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
@jamesmcroft
jamesmcroft / HomepageTests.cs
Created June 28, 2020 16:06
An example test showing how to reference Legerity elements in a test
namespace MyAppTests
{
using System.Threading;
using Legerity;
using Legerity.Windows;
using Legerity.Windows.Elements.Core;
using Legerity.Windows.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
@jamesmcroft
jamesmcroft / BaseTest.cs
Last active June 27, 2020 21:26
A base test class for Windows app UI testing with Legerity
namespace MyAppTests
{
using Legerity;
using Legerity.Windows;
using Microsoft.VisualStudio.TestTools.UnitTesting;
public abstract class BaseTest
{
[TestInitialize]
@jamesmcroft
jamesmcroft / OpenNewWindow.cs
Last active December 14, 2016 17:18
Opens a page as a new window
private async void OnOpenWindowClicked(object sender, RoutedEventArgs e)
{
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne));
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new Size(640, 480));
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new MainPageViewModel());
await WindowHelper.CreateNewWindowForPageAsync(typeof(WindowHelperPageOne), new MainPageViewModel(), new Size(640, 480));
// Also available with type name string.
await WindowHelper.CreateNewWindowForPageAsync("WinUX.Pages.WindowHelperPageOne, WinUX");
}
this.NetworkManager.Start();