コード例 #1
0
 public void Can_get_existing_serviceEvent_by_id()
 {
     IServiceEventRepository repository = new ServiceEventRepository();
     var fromDb = repository.GetById(this.serviceEvents[1].EventId);
     Assert.IsNotNull(fromDb);
     Assert.AreNotSame(this.serviceEvents[1], fromDb);
     Assert.AreEqual(this.serviceEvents[1].Created, fromDb.Created);
     Assert.AreEqual(this.serviceEvents[1].State, fromDb.State);
 }
コード例 #2
0
 public void Can_get_last_x_existing_serviceEvents_by_id()
 {
     IServiceEventRepository repository = new ServiceEventRepository();
     var id = this.serviceEvents[0].ServiceId;
     var fromDb = repository.GetLastServiceEventsById(id, 3);
     Assert.IsNotNull(fromDb);
     Assert.AreNotSame(this.serviceEvents[0], fromDb[0]);
     Assert.That(fromDb.Count, Is.EqualTo(3));
     Assert.AreEqual(this.serviceEvents[0].ServiceId, fromDb[0].ServiceId);
     Assert.AreEqual(this.serviceEvents[0].EventId, fromDb[0].EventId);
     Assert.AreEqual(this.serviceEvents[0].State, fromDb[0].State);
     Assert.AreEqual(this.serviceEvents[0].Created, fromDb[0].Created);
     Assert.AreEqual(this.serviceEvents[1].ServiceId, fromDb[1].ServiceId);
     Assert.AreEqual(this.serviceEvents[1].EventId, fromDb[1].EventId);
     Assert.AreEqual(this.serviceEvents[1].State, fromDb[1].State);
     Assert.AreEqual(this.serviceEvents[1].Created, fromDb[1].Created);
 }
コード例 #3
0
        public void Can_add_new_service_event()
        {
            var serviceEvent = new ServiceEvent { Description = "Desc", State = "Open", Created = new DateTime(2011, 3, 4, 5, 6, 7) };
            IServiceEventRepository repository = new ServiceEventRepository();
            repository.Add(serviceEvent);

            // use session to try to load the service
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<ServiceEvent>(serviceEvent.EventId);
                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(serviceEvent, fromDb);
                Assert.AreEqual(serviceEvent.State, fromDb.State);
                Assert.AreEqual(serviceEvent.Description, fromDb.Description);
                Assert.AreEqual(serviceEvent.EventId, fromDb.EventId);
                Assert.AreEqual(serviceEvent.ServiceId, fromDb.ServiceId);
                Assert.AreEqual(serviceEvent.Created, fromDb.Created);
            }
        }