Skip to content

Instantly share code, notes, and snippets.

PM> Install-Package MockQueryable.Moq
var handler = new GetTodosQuery.GetTodosQueryHandler(mockedDbContext.Object, _mapper);
var mockDbSet = todoListEntities.AsQueryable().BuildMockDbSet();
mockedDbContext.Setup(db => db.TodoLists).Returns(mockDbSet.Object);
var todoListEntities = new List<TodoList>
{
new TodoList{Colour="Blue", Items = new List<TodoItem>{
new TodoItem{Title="Dynamics" },
new TodoItem{Title="Case" },
new TodoItem{Title="Management" },
new TodoItem{Title="Accelerator" },
new TodoItem{Title="HSD" }
}
}
var mockedDbContext = new Mock<IApplicationDbContext>();
[Collection("QueryTests")]
public class GetTodosQueryTests {
private readonly ApplicationDbContext _context;
private readonly IMapper _mapper;
public GetTodosQueryTests(QueryTestFixture fixture) {
_mapper = fixture.Mapper;
}
[Fact]
[Collection("QueryTests")]
public class GetTodosQueryTests {
private readonly ApplicationDbContext _context;
private readonly IMapper _mapper;
public GetTodosQueryTests(QueryTestFixture fixture) {
_context = fixture.Context;
_mapper = fixture.Mapper;
}
@taylorc
taylorc / .gitconfig
Created July 17, 2019 05:25 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
dmerged = "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
st = status
@taylorc
taylorc / view-posts.component.html
Created May 9, 2018 03:21
view-posts.component.html
<div *ngIf="(loading$ | async) === false">
<ul>
<li *ngFor="let p of posts$ | async">
{{p.title}}
</li>
</ul>
</div>
<div *ngIf="(loading$ | async) === true">
Loading.....
</div>
@taylorc
taylorc / view-posts.component.ts
Created May 9, 2018 03:20
view-posts.component.ts
import { Observable } from 'rxjs/Observable';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Select, Store } from '@ngxs/store';
import { FetchPosts } from '../../shared/posts/post.actions';
import { PostState } from '../../shared/posts/post.store';
@Component({