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
$ThisModule = $MyInvocation.MyCommand.Path -replace '\.Tests\.ps1$' | |
$ThisModuleName = $ThisModule | Split-Path -Leaf | |
Get-Module -Name $ThisModuleName -All | Remove-Module -Force -ErrorAction Ignore | |
Import-Module -Name "$ThisModule.psm1" -Force -ErrorAction Stop | |
InModuleScope $ThisModuleName { | |
describe 'ExampleFunction' { | |
it 'Write host with supplied string' { | |
Mock Write-Host {} | |
$expectedMessage = "A"; |
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 Newtonsoft.Json; | |
using System; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Text; | |
using System.Threading.Tasks; | |
public class ApiHttpClientHelper | |
{ | |
public HttpClient Client { get; } |
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 Gt.Fmc.IntegrationTests.Models; | |
public async Task SignalRExample(string hubName, string, hubAction, T exampleParam) | |
{ | |
//ensure we are logged in so that MvcCookieContainer is set allowing us to auth with SignalR Hub. | |
await new MvcHttpClientHelper(MvcHttpClient).LoginHttpRequest(); | |
using (var hubConnection = new HubConnection(Environment.WebSiteUrl)) | |
{ | |
var jobHub = hubConnection.CreateHubProxy(hubName); | |
hubConnection.CookieContainer = MvcCookieContainer; |
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.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
public static class AntiForgeryHelper | |
{ | |
public static string ExtractAntiForgeryToken(string htmlResponseText) | |
{ | |
if (htmlResponseText == null) |
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.Threading.Tasks; | |
using System.Data.SqlClient; | |
using System.Data; | |
namespace Samples | |
{ | |
public abstract class BaseRepository | |
{ | |
protected async Task<T> DbAction<T>(Func<IDbConnection, Task<T>> action, string connectionString = null) |
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 AzureAppServiceAuthenticator | |
{ | |
// Found in the Azure Portal > Azure Active Directory > App Registration (matching Function app name) > Overview > Directory (tenant) ID | |
protected internal const string AzureActiveDirectoryTenantId = "abcd1234-abcd-1234-abcd-1234abcd123"; | |
private static readonly HttpClient HttpClient = new HttpClient(); | |
public async Task<string> GetBearerToken() | |
{ | |
var clientId = GetClientId(); | |
var clientSecret = GetClientSecret(); |
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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"azureSubscriptionId": { | |
"type": "string", | |
"metadata": { | |
"description": "The azure subscription Id. Something like 12345678-abcd-abcd-abcd-1234567890ab." | |
} | |
}, |
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
--Start with this file, rename and remove as required. | |
--Use PascalCase for table names and column names. | |
-- create new table with composite PK; this is OK if there is a clear and simple PK from one or two other columns | |
if not exists(select * from sys.tables t where t.name = 'TableName') | |
begin | |
create table TableName | |
( | |
CompositeId1 int not null, | |
CompositeId2 int not null, |