public void should_save_and_load()
        {
            var entity = new ExampleEntity("test");
            var newEntity = VerifyPersistence(entity);

            newEntity.ShouldBeEquivalentTo(entity, DefaultCompareConfig.Compare);
        }
        public ExampleModule(IRepositoryOfId<int> repository, IMappingEngine engine, ISendOnlyBus bus)
        {
            Get["/examples"] = _ => repository.Query<ExampleEntity>()
                .Project().To<ExampleModel>()
                .ToList();

            Get["/example/{id:int}"] = _ => {
                var entity = repository.Load<ExampleEntity>(_.id);
                return engine.Map<ExampleEntity, ExampleModel>(entity);
            };

            Post["/examples"] = _ => {
                var model = this.BindAndValidateModel<NewExampleModel>();

                var entity = new ExampleEntity(model.Name);
                repository.Save(entity);

                return new NewExampleCreatedModel { Id = entity.ID };
            };

            Post["/examples/close"] = _ => {
                var model = this.BindAndValidateModel<CloseExampleModel>();
                bus.Send(new CloseExampleCommand {Id = model.Id});
                return HttpStatusCode.OK;
            };

            Delete["/example/{id:int}"] = _ => {
                repository.Delete<ExampleEntity>(_.id);
                return HttpStatusCode.OK;
            };
        }
        public void should_create_example_entity()
        {
            var now = DateTime.Now;
            var entity = new ExampleEntity(NAME);

            entity.Name.Should().Be(NAME);
            entity.Status.Should().Be(ExampleStatus.Open);
            entity.Timestamp.DateCreated.Should().BeWithin(1.Seconds()).After(now);
            entity.Timestamp.DateUpdated.Should().BeWithin(1.Seconds()).After(now);
        }
        public void should_update_status_to_closed()
        {
            var created = DateTime.Now;
            var entity = new ExampleEntity(NAME);

            var updated = DateTime.Now;
            entity.Close();

            entity.Status.Should().Be(ExampleStatus.Closed);
            entity.Timestamp.DateCreated.Should().BeWithin(1.Seconds()).After(created);
            entity.Timestamp.DateUpdated.Should().BeWithin(1.Seconds()).After(updated);
        }