Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Amarok79/CodeRush.Templates.NFluent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

Introduction

This project provides a set of C#-based Code Templates for CodeRush targeted explicitly at writing unit tests with NFluent. For more information about CodeRush Code Templates refer to the official CodeRush Documentation.

Under Releases you can find XML files containing templates. These can be easily imported in CodeRush's Template Configuration.

How to Use

For NFluent-style assertions, you typically start with template kk followed by Space which expands to:

Check.That(<value>)

You can then enter the value to check, hit Enter, and then use one of the various templates from below, for example, isf, which expands to:

Check.That(<value>)
    .IsFalse()

Enter the final semicolon, hit Enter again and done. Start again with kk for the next assertion.

Templates

General Templates

Template Code
kk Check.That(value)
ise .IsEqualTo(expected)
isne .IsNotEqualTo(expected)
is0 .IsEqualTo(0)
is1 .IsEqualTo(1)
is2 .IsEqualTo(2)
isf .IsFalse()
ist .IsTrue()
isz .IsEqualTo(0)
isn .IsNull()
isnn .IsNotNull()
isem .IsEmpty()
isnem .IsNotEmpty()
iss .IsSameReferenceAs(expected)
isns .Not.IsSameReferenceAs(expected)
idf .IsDistinctFrom(expected)
iio .IsInstanceOf<Type>()
iiot .IsInstanceOfType(expected)
inio .IsNotInstanceOf<Type>()
iniot .IsNoInstanceOfType(expected)
ioo .IsOneOf(expected)
hsf .HasFieldsWithSameValues(expected)
hnsf .HasNotFieldsWithSameValues(expected)

Collection-specific Templates

Template Code
con .Contains(expected)
cone .ContainsExactly(expected)
iomo .IsOnlyMadeOf(expected)
ieqt .IsEquivalentTo(expected)
hs .HasSize(expected)
hfe .HasFirstElement().Which
hle .HasLastElement().Which
hea .HasElementAt(index).Which

String-specific Templates

Template Code
isnoem .IsNullOrEmpty()
isnows .IsNullOrWhiteSpace()
iseic .IsEqualIgnoringCase(expected)
stw .StartsWith(expected)
enw .EndsWith(expected)
mat .Matches(expected)
matwc .MatchesWildcards(expected)
ncon .DoesNotContain(expected)
nmat .DoesNotMatch(expected)

Codeblock Templates

Template Code
kkc Check.ThatCode(() => code-block)
kkcc Check.ThatCode(() => { code-block })
kkac Check.ThatAsyncCode(async () => code-block)
kkacc Check.ThatAsyncCode(async () => { code-block })
kkct Check.ThatCode(() => code-block).Throws<Exception>();
kkact Check.ThatAsyncCode(async () => code-block).Throws<Exception>();