public void TestInit() { AutomapperConfig.CreateMapping(); this.lanes = new List<Lane>(); this.timeSlots = new List<TimeSlot>(); DependencyResolverInitializer.Initialize(); this._configuration = ServiceLocator.Current.GetInstance<Configuration>(); this._sessionFactory = LocalSessionInitializer.Initialize(); this._session = this._sessionFactory.GetCurrentSession(); new SchemaExport(_configuration).Execute(true, true, false); // add some lanes and timeslots to the database // there are timeslots from 1000 hours => 2300 hours for (int i = 0; i < 10; i++) { var timeSlot = new TimeSlot() { Start = TimeSpan.FromHours(10 + i), End = TimeSpan.FromHours(11 + i) }; this.timeSlots.Add(timeSlot); _session.Save(timeSlot); var lane = new Lane() { Name = (i + 1).ToString() }; this.lanes.Add(lane); _session.Save(lane); } }
public virtual bool AddLane(Lane lane) { if (this.lanes.Contains(lane)) { return false; } Lanes.Add(lane); return true; }
public void TestAddingSameLaneReturnsFalse() { var lane1 = new Lane { Name = "42" }; var lane2 = new Lane { Name = "45" }; this._session.Save(lane1); this._session.Save(lane2); Reservation resv = new Reservation(); Assert.That(resv.AddLane(lane1), Is.True); Assert.That(resv.AddLane(lane2), Is.True); Assert.That(resv.AddLane(lane1), Is.False); }
public void TestReservationCRUD() { var theLanes = new Lane[] { new Lane { Name = "1" }, new Lane { Name = "2" }, new Lane { Name = "3" } }; var theSlots = new TimeSlot[] { new TimeSlot { Start = new TimeSpan(13, 0, 0), End = new TimeSpan(14, 0,0) }, new TimeSlot { Start = new TimeSpan(14, 0, 0), End = new TimeSpan(15, 0,0) }, new TimeSlot { Start = new TimeSpan(15, 0, 0), End = new TimeSpan(16, 0,0)} }; foreach (var lane in theLanes) { this._session.Save(lane); } foreach (var slot in theSlots) { this._session.Save(slot); } new PersistenceSpecification<Reservation>(this._session) .CheckProperty(c => c.Id, 1) .CheckProperty(c => c.Name, "John Doe") .CheckProperty(c => c.CreatedAt, DateTime.Now, new DateTimeEqualityComparer()) .CheckProperty(c => c.NumberOfPlayers, 6) .CheckProperty(c => c.PhoneNumber, 12345678) .CheckProperty(c => c.PlayAt, DateTime.Now.AddDays(1), new DateTimeEqualityComparer()) .CheckProperty(c => c.Status, ReservationStatus.Pending) .CheckReference( c => c.Member, new Member() { Email = "*****@*****.**", DefaultNumberOfPlayers = 42, DialCode = "+45", Name = "John Doe", Password = "******", ReceiveNewsLetter = true, Title = MemberTitle.Dr }) .CheckComponentList( x => x.Lanes, theLanes,(r, l) => { r.AddLane(l); }) .CheckComponentList( x => x.TimeSlots, theSlots, (r, t) => { r.AddTimeSlot(t); }) .VerifyTheMappings(); }