Beispiel #1
0
        static public void LoadBeds(BedManagerContext context)
        {
            var Hosp = new Hospital("New Hosp 1");

            context.Hospitals.Add(Hosp);
            context.SaveChanges();

            var Room = Hosp.AddRoom(2);

            context.SaveChanges();
            Room.AddBed("Descrip_1", false);
            Room.AddBed("Descrip_2", true);
            context.SaveChanges();

            var Room2 = Hosp.AddRoom(1);

            context.SaveChanges();
            Room2.AddBed("Descrip_3", false);
            var Pat4 = new Patient("Finn", "Shark");
            var Bed4 = Room2.AddBed("Descrip_4", true);

            Pat4.AssignBed(Bed4);

            context.SaveChanges();
        }
Beispiel #2
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new BedManagerContext(
                       serviceProvider.GetRequiredService <DbContextOptions <BedManagerContext> >()))
            {
                var Hosp = new Hospital("New Hosp 1");
                context.Hospitals.Add(Hosp);
                context.SaveChanges();

                var Room = Hosp.AddRoom(2);
                context.SaveChanges();
                Room.AddBed("Descrip_1", true);
                Room.AddBed("Descrip_2", false);
                context.SaveChanges();

                var Room2 = Hosp.AddRoom(1);
                context.SaveChanges();
                Room2.AddBed("Descrip_3", false);
                var Pat4 = new Patient("Finn", "Shark");
                var Bed4 = Room2.AddBed("Descrip_4", true);
                Pat4.AssignBed(Bed4);
                context.SaveChanges();
            }
        }
Beispiel #3
0
        public void MaxRooms()
        {
            DbContextOptionsBuilder <BedManagerContext> optbldr = new DbContextOptionsBuilder <BedManagerContext>().UseInMemoryDatabase("UnitTest1_MaxRooms");
            DbContextOptions <BedManagerContext>        options = optbldr.Options;
            BedManagerContext context = new BedManagerContext(options);

            TestData.LoadBeds(context);
            var Hosp = context.Hospitals.Include(p => p.Rooms).ThenInclude(r => r.Beds).ToList().First();

            var room = Hosp.Rooms.First();

            for (int i = 0; i <= room.MaxBeds + 1; i++)
            {
                var bedname = string.Format("new Bed {0}", i);
                var Bed     = room.AddBed(bedname, true);
            }

            context.SaveChanges();

            Assert.AreEqual(room.MaxBeds, room.Beds.Count());
        }
Beispiel #4
0
        public void AssignPatient()
        {
            DbContextOptionsBuilder <BedManagerContext> optbldr = new DbContextOptionsBuilder <BedManagerContext>().UseInMemoryDatabase("UnitTest1_AssignPatient");
            DbContextOptions <BedManagerContext>        options = optbldr.Options;
            BedManagerContext context = new BedManagerContext(options);

            TestData.LoadBeds(context);
            var Hosp = context.Hospitals.Include(p => p.Rooms).ThenInclude(r => r.Beds).ToList().First();
            var Bed  = Hosp.GetBeds().First();


            var Pat = new Patient("Me", "Ma");

            context.Add(Pat);
            Pat.AssignBed(Bed);
            context.SaveChanges();
            var Result = context.Beds.Where(b => b.Id == Bed.Id).FirstOrDefault();

            Assert.AreNotEqual(0, Pat.Id);
            Assert.AreEqual(Pat.Id, Result.PatientId);
            Assert.AreEqual(true, Bed.GetCurrentStatus().IsClean);
        }