Skip to content

Instantly share code, notes, and snippets.

View philippdolder's full-sized avatar

Philipp Dolder philippdolder

View GitHub Profile
@philippdolder
philippdolder / gist:7e2ea55a256e834fe017
Created June 2, 2014 14:50
Possible with R# Search&Replace Pattern?
namespace SearchPattern
{
using NUnit.Framework;
[TestFixture]
public class SearchPatternFakeTest
{
private Worker testee;
[SetUp]
@philippdolder
philippdolder / Error Log Octopus
Created August 21, 2014 11:14
Error Log Octopus
Deploying Server 4.6.317 to: Server Sanity Testing (Guided Failure: Not Enabled)
[13:05:59]Error from Octopus server (HTTP 403): You do not have permission to perform this action. Please contact your Octopus administrator.
[13:05:59]Exit code: -7
[13:05:59]Octo.exe exit code: -7
@philippdolder
philippdolder / Not working
Created November 25, 2014 06:52
AutoMapper constructor
public class Test
{
[Fact]
public void MapChildViewModel()
{
Mapper.CreateMap<ViewModel, Dto>();
var childViewModel = new ChildViewModel
{
ChildId = 5,
@philippdolder
philippdolder / cmdlet.ps1
Last active August 29, 2015 14:10
git-tfs workflow
function Tfs-UpdateFeature {
[CmdletBinding()]
param ()
DynamicParam {
$RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
$FeatureParameter = New-DynamicParameter -ParameterName "Feature" -AllowedValues {(git branch --list) | ForEach-Object { $_.Substring(2) }} -Position 0 -Aliases @("b","f") -Mandatory
$BranchParameter = New-DynamicParameter -ParameterName "MainBranch" -AllowedValues {(git branch --list) | ForEach-Object { $_.Substring(2) }} -Position 1
@philippdolder
philippdolder / Collection Count
Created March 23, 2015 07:08
R# SSP: MsTest to FluentAssertions collection count
The expression in the code looks like this:
var list = new List<string>();
Assert.AreEqual(3, list.Count);
Search part of ssp:
Assert.AreEqual($expected$, $actual$.Count);
both variables match "exactly one argument". I've turned on "Match similar constructs"
Replace part of ssp:
public static class MyCollectionAssertionExtensions
{
public static AndConstraint<StringCollectionAssertions> ContainMagic(this StringCollectionAssertions assertions)
{
Execute.Assertion
.ForCondition(assertions.Subject.As<MyType>().ContainsMagicString())
.FailWith("No, there's no magic");
return new AndConstraint<StringCollectionAssertions>(assertions);
}
@philippdolder
philippdolder / HowCanIUseItProperly.cs
Last active August 29, 2015 14:19
FluentAssertions. Assert multiple exceptions.
// I would like to make sure, both exceptions are packed into the AggregateException
[TestMethod]
public void ShouldThrowAggregateException()
{
Action act = () =>
{
throw new AggregateException(new Exception(), new ArgumentException());
};
act.ShouldThrow<AggregateException>()
@philippdolder
philippdolder / JsonTextDeserializerOnly.cs
Created September 28, 2015 15:35
NEventStore simple dumper
public class JsonTextDeserializerOnly : ISerialize
{
public void Serialize<T>(Stream output, T graph)
{
throw new NotSupportedException("serialization should not be required");
}
public T Deserialize<T>(Stream input)
{
if (typeof(T) == typeof(List<EventMessage>))
@philippdolder
philippdolder / FluentAssertionsMessages.cs
Created August 28, 2012 07:42
Shortened messages in FluentAssertions
// The verification is as follows:
Execute.Verification
.ForCondition(elementsWithCorrectValue.Any)
.FailWith(string.Concat(Message, " with name {2} and value {3}"), assertions.Subject, elementName, name, elementValue);
// The error message with 1.7.1.1 is:
Expected collection
{<Field Name=\"fieldName\">...</Field>}
to contain a "Field" element with name "fieldName" and value "before\r\nafter"
@philippdolder
philippdolder / gist:3497513
Created August 28, 2012 11:57
FluentAssertionsException
System.IO.FileNotFoundException
Could not load file or assembly 'JetBrains.ReSharper.Psi, Version=7.0.58.117, Culture=neutral, PublicKeyToken=1010a0d8d6380325' or one of its dependencies. The system cannot find the file specified.
The stacktrace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex05\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs: line 125
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)