Skip to content

Instantly share code, notes, and snippets.

set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" Kotlin Vim Plugin # https://github.com/udalov/kotlin-vim
Plugin 'udalov/kotlin-vim'
" Syntax checking # https://github.com/vim-syntastic/syntastic
@johanvergeer
johanvergeer / .editorconfig
Last active April 23, 2019 06:43
My default EditorConfig for C# projects
# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Workspace\Uniforms codebase based on best match to current usage at 12-4-2019
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]
#Core editorconfig formatting - indentation
#use soft tabs (spaces) for indentation
indent_style = space
indent_size = 4
@johanvergeer
johanvergeer / PersonModel.cs
Last active May 19, 2019 13:56
Simple Person model
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public bool IsValid => !string.IsNullOrWhiteSpace(this.Name);
}
@johanvergeer
johanvergeer / IPersonRepository.cs
Last active May 19, 2019 14:08
Person Repository interface
public interface IPersonRepository
{
IReadOnlyCollection<Person> FindAll();
void Add(Person person);
}
@johanvergeer
johanvergeer / PersonController.cs
Created May 19, 2019 14:09
Person API Controller
[Route("api/[controller]")]
[ApiController]
public class PersonController : Controller
{
private readonly IPersonRepository _repository;
public PersonController(IPersonRepository _repository)
{
this._repository = _repository;
}
@johanvergeer
johanvergeer / PersonControllerSpec.cs
Created May 19, 2019 14:24
PersonControllerSpect with IPersonRepository mock
public class PersonControllerSpec
{
private readonly Mock<IPersonRepository> _repository;
public PersonControllerSpec()
{
this._repository = new Mock<IPersonRepository>();
}
}
@johanvergeer
johanvergeer / PersonControllerSpec.Get_NoArgs_ReturnsEmptyList.cs
Last active May 19, 2019 14:32
Test method for PersonController returning an empty list of Person
[Fact]
public void Get_NoArgs_ReturnsEmptyList()
{
// Setup repository to return an empty list
this._repository.Setup(r => r.FindAll())
.Returns(new List<Person>());
// Pass the mock repository to the controllers constructor
var controller = new PersonController(this._repository.Object);
@johanvergeer
johanvergeer / PersonControllerSpec.Get_NoArgs_ReturnsAllPeople.cs
Last active May 19, 2019 14:41
Expect three Person objects to return
[Fact]
public void Get_NoArgs_ReturnsAllPeople()
{
var people = new List<Person>
{
new Person {Name = "Johan", Age = 37},
new Person {Name = "Angela", Age = 34},
new Person {Name = "Robert", Age = 36}
};
@johanvergeer
johanvergeer / PersonControllerSpec.Post_Person_PersonSaved.cs
Created May 19, 2019 14:50
Post Person object to PersonController
[Fact]
public void Post_Person_PersonSaved()
{
// Create person to post to controller
var person = new Person {Name = "Johan", Age = 37};
// Create new controller with mock repository
var controller = new PersonController(this._repository.Object);
// Call controller to post person
[Fact]
public void Post_PersonWithoutName_PersonNotSaved()
{
// Create new person, without a name, which will not be accepted by the controller
var person = new Person();
// Create new controller with mock repository
var controller = new PersonController(this._repository.Object);
// Call controller to post person