Skip to content

Instantly share code, notes, and snippets.

View AndyWatt83's full-sized avatar

Andy Watt AndyWatt83

View GitHub Profile
@AndyWatt83
AndyWatt83 / Dockerfile
Created May 4, 2021 21:25
truffle-suite Dockerfile
ARG VARIANT="focal"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
USER root
WORKDIR /home/app
RUN apt-get update
RUN apt-get -y install curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get -y install nodejs
RUN npm install
RUN npm install -g truffle@5.3.4
@AndyWatt83
AndyWatt83 / MigrationsTest.cs
Last active December 1, 2021 23:37
Unit testing entity framework migrations
using Dapper;
using FluentAssertions;
using Npgsql;
using System;
using Xunit;
namespace SampleDatabase.Test
{
[TestCaseOrderer("TestingEntityFramework.MigrationTestOrderer", "TestingEntityFramework")]
public class MigrationsTest : IClassFixture<MigratingDatabaseFixture>
<Project>
<Target Name="VSTest">
<MSBuild Projects="@(ProjectReference)" Targets="VSTestIfTestProject" />
</Target>
</Project>
<Project>
<Target Name="VSTestIfTestProject">
<CallTarget Targets="VSTest" Condition="'$(IsTestProject)' == 'true'" />
</Target>
</Project>
@AndyWatt83
AndyWatt83 / truffleTestHelperExamples.js
Last active November 26, 2020 15:46
Shows how the evm_mine, and evm_increaseTime helper wrappers are used in an actual test.
const helper = require("./helpers/truffleTestHelper");
describe("Testing Helper Functions", () => {
it("should advance the blockchain forward a block", async () =>{
const originalBlockHash = web3.eth.getBlock('latest').hash;
let newBlockHash = web3.eth.getBlock('latest').hash;
newBlockHash = await helper.advanceBlock();
assert.notEqual(originalBlockHash, newBlockHash);
@AndyWatt83
AndyWatt83 / truffleTestHelper.js
Created July 21, 2018 23:53
A helper file with a couple of functions for advancing the blockchain in time, and blocks.
advanceTimeAndBlock = async (time) => {
await advanceTime(time);
await advanceBlock();
return Promise.resolve(web3.eth.getBlock('latest'));
}
advanceTime = (time) => {
return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync({
pragma solidity ^0.4.18;
import "./ConvertLib.sol";
// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!
contract MetaCoin {
<Window x:Class="WireFrame.Shell.Shell"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WireFrame.Shell"
mc:Ignorable="d"
Title="Shell" Height="450" Width="600">
<Window.Resources>
<Thickness x:Key="BtnMargin">5,5,5,0</Thickness>
using System.Windows;
namespace TaskList.Shell
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var bootstrapper = new Bootstrapper();
using Prism.Mef;
using System.ComponentModel.Composition.Hosting;
using System.Windows;
namespace WireFrame.Shell
{
class Bootstrapper : MefBootstrapper
{
protected override DependencyObject CreateShell()
{