Skip to content

Instantly share code, notes, and snippets.

@urasandesu
urasandesu / DateTimeHelper.cs
Created May 21, 2016 04:42
Example for mocking the instance method of a struct. I added the feature to Prig because I knew that Microsoft Fakes doesn't support [it](https://social.msdn.microsoft.com/Forums/en-US/3be5abc6-1b21-4322-a1f6-9573d38c4885/can-we-use-fakes-to-test-automationelement-methods?forum=vsunittest).
using System;
namespace StructInstanceMethodSample
{
public class DateTimeHelper
{
public static DateTime ConvertServerTimeToTimeZoneTime(DateTime inputDateTime, string zoneId, bool __no_use__)
{
// dummy implementation
var utcDateTime = inputDateTime.ToUniversalTime();
@urasandesu
urasandesu / AutoFixture.AutoMoq.Prig.spike.cs
Created March 29, 2016 11:56
Prototype: AutoFixture with auto mocking using Moq and Prig
using Moq;
using Moq.Language;
using NUnit.Framework;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.Kernel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.Prig;
@urasandesu
urasandesu / profile.ps1
Created March 6, 2016 11:34
profile.ps1 for PSUnit
#PSUnit: Setting up PATH environment variable to point to PSUnit framework
$PSUnitPath = "C:\psunit-2-beta-1-24978" #Modify this path to match your local PowerShell installation path
#Make sure to only append this path once
if (!($env:path -like "*$PSUnitPath*"))
{
$env:path = $env:path + ";$PSUnitPath"
}
#PSUnit: Setting PSUNIT_HOME environment variable to point to PSUnit framework
If(! $(Test-Path -Path "env:PSUNIT_HOME"))
{
@(33..126 | Get-Random -Count 8 | % { [char]$_ }) -join ''
# sample result:
# 0_&fp$Se
@urasandesu
urasandesu / VSIXInstaller_048d7422-dde7-4db7-aefb-9e385b5ed4e1.log
Created November 18, 2015 13:09
VSIX Installerの「インストールが正常に完了してるのに、内部的にはインストールされていない状況」のログ
2015/11/18 22:00:57 - Microsoft VSIX Installer
2015/11/18 22:00:57 - -------------------------------------------
2015/11/18 22:00:57 - Initializing Install...
2015/11/18 22:00:57 - 拡張機能の詳細...
2015/11/18 22:00:57 - Identifier : 0a06101d-8de3-40c4-b083-c5c16ca227ae
2015/11/18 22:00:57 - Name : Prig Test Adapter
2015/11/18 22:00:57 - Author : Urasandesu
2015/11/18 22:00:57 - Version : 2.0.0
2015/11/18 22:00:57 - Description : Visual Studio Integrated Test Adapter for Prig. Prig(PRototyping jIG) is a framework that generates a Test Double like Microsoft Fakes/Typemock Isolator/Telerik JustMock based on Unmanaged Profiler APIs. This framework enables that any methods are replaced with mocks. For example, a static property, a private method, a non-virtual member and so on.
2015/11/18 22:00:57 - Locale : en-US
@urasandesu
urasandesu / ConvertDelegateWithoutCast.cs
Created August 2, 2015 01:19
キャストせずにデリゲート A から同じシグネチャのデリゲート B に変換
using System;
using System.Linq;
using System.Reflection.Emit;
namespace ConvertDelegateWithoutCast
{
class Program
{
static void Main(string[] args)
{
@urasandesu
urasandesu / Get-HelpByMarkdown.ps1
Last active August 5, 2023 04:12
This script converts PowerShell comment-based help to GitHub Flavored Markdown.
#
# File: Get-HelpByMarkdown.ps1
#
# Author: Akira Sugiura ([email protected])
#
#
# Copyright (c) 2014 Akira Sugiura
#
# This software is MIT License.
#
@urasandesu
urasandesu / ConsoleApplication43.cpp
Created October 5, 2014 09:40
Microsoft Z3 の C++ API に、.NET API にある Context.ParseSMTLIB2String を追加する試み
// ConsoleApplication43.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include "stdafx.h"
namespace z3 {
class context_ex :
public context
using Moq;
using NUnit.Framework;
namespace MoqVerifyBehaviorDemo
{
[TestFixture]
public class MoqVerifyBehaviorTest
{
[Test]
public void Setup_with_argument_matcher_and_Setup_with_constant_should_be_same_behavior()
using FluentAssertions;
using NUnit.Framework;
using System.Collections.Generic;
namespace ClassLibrary
{
[TestFixture]
public class FluentAssertionsSample
{
[Test]