public void ReturnsNull_WhenIdCannotBeMatched() { const int id = 9; var query = new GetEstablishmentByIdQuery(id); var establishments = new Establishment[] {}.AsQueryable(); var entities = new Mock<IQueryEntities>(MockBehavior.Strict); entities.Setup(p => p.Query<Establishment>()).Returns(establishments); var handler = new GetEstablishmentByIdHandler(entities.Object); var result = handler.Handle(query); result.ShouldBeNull(); }
public void ReturnsEstablishment_WhenIdCanBeMatched() { const int id = 6; var query = new GetEstablishmentByIdQuery(id); var establishment = new Establishment { RevisionId = id, }; var establishments = new[] { establishment, }.AsQueryable(); var entities = new Mock<IQueryEntities>(MockBehavior.Strict); entities.Setup(p => p.Query<Establishment>()).Returns(establishments); var handler = new GetEstablishmentByIdHandler(entities.Object); var result = handler.Handle(query); result.ShouldNotBeNull(); result.RevisionId.ShouldEqual(id); }