public void Can_get_existing_service_by_id()
 {
     IServiceRepository repository = new ServiceRepository();
     var fromDb = repository.GetById(_services[1].Id);
     Assert.IsNotNull(fromDb);
     Assert.AreNotSame(_services[1], fromDb);
     Assert.AreEqual(_services[1].Name, fromDb.Name);
 }
        public void Can_remove_existing_service()
        {
            var service = this._services[0];
            IServiceRepository repository = new ServiceRepository();
            repository.Remove(service);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Service>(service.Id);
                Assert.IsNull(fromDb);
            }
        }
        public void Can_add_new_service()
        {
            var service = new Service { Name = "Build", Description = "Build stuff" };
            IServiceRepository repository = new ServiceRepository();
            repository.Add(service);

            // use session to try to load the service
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Service>(service.Id);
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(service, fromDb);
                Assert.AreEqual(service.Name, fromDb.Name);
                Assert.AreEqual(service.Description, fromDb.Description);
            }
        }
        public void Can_update_existing_service()
        {
            var service = this._services[0];
            service.Name = "endpoint";
            IServiceRepository repository = new ServiceRepository();
            repository.Update(service);

            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Service>(service.Id);
                Assert.AreEqual(service.Name, fromDb.Name);
            }
        }