Skip to content

Instantly share code, notes, and snippets.

@scrooby
scrooby / gist:698f29844995f39341a4ceb02434c3b3
Created May 5, 2016 15:35
flatten object to key value pairs
const identifiers = {
id: 1,
referenceNumber: '123'
};
const convert = R.compose(R.map(R.zipObj(['key', 'value'])), R.toPairs);
convert(identifiers);
@scrooby
scrooby / gist:2cb462d00d44a7b502b209438836eb02
Created July 13, 2016 10:23
FAKE dotCover coverage TeamCity integration
Target "TestCoverage" (fun _ ->
let filters = ""
!! unitTestsFiles
|> DotCoverNUnit3 (fun p ->
{ p with
Output = artifactsDir @@ "NUnitDotCover.snapshot"
Filters = filters }) nunitOptions
tracefn "##teamcity[importData type='dotNetCoverage' tool='dotcover' path='%s']" (artifactsDir @@ "NUnitDotCover.snapshot")
@scrooby
scrooby / SeleniumHooks.cs
Last active November 18, 2016 15:52
Retrieve the browser logs using Selenium and write them out to the console after each scenario
[AfterScenario(Order = 0)]
public void ErrorHandling()
{
WriteBrowserLogs();
}
private void WriteBrowserLogs()
{
var driverType = SeleniumController.Instance.DriverType;
if (driverType != SeleniumDriverType.Chrome)
@scrooby
scrooby / gist:4415bc108858d7a70d5f2e5c010011dc
Created November 25, 2016 09:35
Write a X509Certificate public key in PEM format
var cert = Org.BouncyCastle.Security.DotNetUtilities.FromX509Certificate(x509certificate);
using (var stringWriter = new StringWriter())
{
var pemWriter = new Org.BouncyCastle.OpenSsl.PemWriter(stringWriter);
pemWriter.WriteObject(cert.GetPublicKey());
var pem = stringWriter.ToString();
}
@scrooby
scrooby / ReconciliationSubmissionSaga.cs
Created February 3, 2017 11:21
Sample NServiceBus saga SpecFlow test that results in event message going to the error queue with error message "Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)". Some of the code has been flattened for example purposes, but the test does run and results in the same error hitting the queue.
public class ReconciliationSubmissionSaga : Saga<ReconciliationSubmissionSagaData>,
IAmStartedByMessages<StartReconciliationSubmissionCommand>,
IHandleMessages<StoreManualAgreementReconciliationFailedEvent>,
...
{
...
public Task Handle(StoreManualAgreementReconciliationFailedEvent message, IMessageHandlerContext context)
{
Data.SagaState = "StoreManualAgreementReconciliationFailed";