public void StartNight_Homeless()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    hR = new HotelRoomRepository(c);
            ITamagotchiRepository   tR = new TamagotchiRepository(c);


            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name  = "Test",
                Alive = true
            };
            TamagotchiViewModel t2 = new TamagotchiViewModel()
            {
                Name   = "Test2",
                Alive  = true,
                Health = 10,
            };

            tR.Add(t);
            tR.Add(t2);

            NightController nC = new NightController(tR, hR);

            nC.StartNight();

            Assert.IsTrue(tR.Find(t.Id).Boredom == 20);
            Assert.IsTrue(tR.Find(t.Id).Health == 80);

            Assert.IsTrue(tR.Find(t2.Id).Health == 0);
            Assert.IsTrue(tR.Find(t2.Id).Alive == false);
        }
        public void StartNight_Gameroom()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    hR = new HotelRoomRepository(c);
            ITamagotchiRepository   tR = new TamagotchiRepository(c);

            HotelRoomViewModel h = new HotelRoomViewModel()
            {
                Size = 5,
                Type = HotelRoomType.Gameroom,
            };

            hR.Add(h);

            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name        = "Test",
                Alive       = true,
                HotelRoom   = h,
                HotelRoomId = h.Id,
                Boredom     = 50
            };

            tR.Add(t);

            NightController nC = new NightController(tR, hR);

            nC.StartNight();

            Assert.IsTrue(tR.Find(t.Id).Boredom == 0);
            Assert.IsTrue(tR.Find(t.Id).Pennies == 80);
        }
Beispiel #3
0
        public void BookingController_CreateBooking()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    hr = new HotelRoomRepository(c);
            ITamagotchiRepository   tr = new TamagotchiRepository(c);
            BookingController       bc = new BookingController(hr, tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Customer);
            bc.ControllerContext = ccMock.Object;
            FormCollection fc = new FormCollection();


            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name  = "Test",
                Alive = true
            };

            tr.Add(t);
            HotelRoomViewModel h = new HotelRoomViewModel()
            {
                Size = 5,
                Type = HotelRoomType.Fightroom
            };

            hr.Add(h);
            fc.Add("1", "true,false");
            bc.Create(fc, h);
            Assert.AreEqual(t.ToModel().HotelRoomId, tr.Find(t.Id).HotelRoomId);
            tr.Remove(t);
            hr.Remove(h);
        }
 public DataAccessAction(ApplicationDbContext context)
 {
     _context         = context;
     HotelRooms       = new HotelRoomRepository(_context);
     Guests           = new GuestRepository(_context);
     Reservations     = new ReservationRepository(_context);
     ApplicationUsers = new ApplicationUserRepository(_context);
 }
 public HotelBookingController(
     HotelBookingRepository hotelBookingRepository,
     HotelRoomRepository hotelRoomRepository,
     TamagotchiRepository tamagotchiRepository)
 {
     this._hotelBookingRepository = hotelBookingRepository;
     this._hotelRoomRepository    = hotelRoomRepository;
     this._tamagotchiRepository   = tamagotchiRepository;
 }
 public HTService(HotelRoomRepository hotelRoomRepository,
                  HotelRoomTypeRepository hotelRoomTypeRepository,
                  PlayerUserRepository playerUserRepository,
                  TamagotchiRepository tamagotchiRepository)
 {
     this._hotelRoomRepository     = hotelRoomRepository;
     this._hotelRoomTypeRepository = hotelRoomTypeRepository;
     this._playerUserRepository    = playerUserRepository;
     this._tamagotchiRepository    = tamagotchiRepository;
 }
Beispiel #7
0
 public HotelRoomsController(
     HotelRoomRepository hotelRoomRepository,
     HotelRoomTypeRepository hotelRoomTypeRepository,
     HotelRoomSizeRepository hotelRoomSizeRepository
     )
 {
     this._hotelRoomRepository     = hotelRoomRepository;
     this._hotelRoomTypeRepository = hotelRoomTypeRepository;
     this._hotelRoomSizeRepository = hotelRoomSizeRepository;
 }
Beispiel #8
0
        public void About()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            ITamagotchiRepository   tR = new TamagotchiRepository(c);
            IHotelRoomRepository    hR = new HotelRoomRepository(c);

            // Arrange
            HomeController controller = new HomeController(hR, tR);;

            // Act
            ViewResult result = controller.About() as ViewResult;

            // Assert
            Assert.AreEqual("Programmeren 6 assessment by Bram-Boris Meerlo and Peter-Jan Gootzen", result.ViewBag.Message);
        }
Beispiel #9
0
        public void Index()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            ITamagotchiRepository   tR = new TamagotchiRepository(c);
            IHotelRoomRepository    hR = new HotelRoomRepository(c);

            // Arrange
            HomeController controller = new HomeController(hR, tR);

            // Act
            ViewResult result = controller.Index() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Beispiel #10
0
 public UnitOfWork(
     FarTrekDbContext context,
     IMapper mapper,
     IOptions <AppSettings> appSettings
     )
 {
     _context          = context;
     _mapper           = mapper;
     _appSettings      = appSettings;
     Users             = new UserRepository(_appSettings, context, _mapper);
     Guests            = new GuestRepository(context);
     Hotels            = new HotelRepository(context);
     ReservationGuests = new ReservationGuestsRepository(context);
     Reservations      = new ReservationRepository(context);
     Rooms             = new RoomRepository(context);
     HotelRooms        = new HotelRoomRepository(context);
 }
 public RoomFactory(
     HotelBookingRepository hotelBookingRepository,
     HotelRoomRepository hotelRoomRepository,
     TamagotchiRepository tamagotchiRepository,
     Dictionary <string, IRoom> rooms
     )
 {
     this._hotelBookingRepository = hotelBookingRepository;
     this._hotelRoomRepository    = hotelRoomRepository;
     this._tamagotchiRepository   = tamagotchiRepository;
     this._rooms          = rooms;
     _rooms["Rest room"]  = new RestRoom();
     _rooms["Game room"]  = new GameRoom();
     _rooms["Fight room"] = new FightRoom();
     _rooms["Work room"]  = new WorkRoom();
     _rooms["Love room"]  = new LoveRoom();
     _rooms["No room"]    = new NoRoom();
 }
Beispiel #12
0
        public void Test_DeleteConfirmed()
        {
            HotelRoomViewModel t = new HotelRoomViewModel()
            {
                Size = 2,
                Type = HotelRoomType.Workroom
            };
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    tr = new HotelRoomRepository(c);
            HotelRoomController     tc = new HotelRoomController(tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Staff);
            tc.ControllerContext = ccMock.Object;

            tc.Create(t);
            tc.DeleteConfirmed(t.Id);

            Assert.IsFalse(tr.GetAll().Contains(t));
        }
Beispiel #13
0
        public void Test_Errors()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    tr = new HotelRoomRepository(c);
            HotelRoomController     tc = new HotelRoomController(tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Staff);
            tc.ControllerContext = ccMock.Object;

            var r  = tc.Delete(null);
            var r2 = tc.Delete(0);
            var r3 = tc.Edit(0);

            //Untestable because null is ambigious between a int? and an object
            //var r3 = tc.Edit(null);

            Assert.That(r, Is.TypeOf <HttpStatusCodeResult>());
            Assert.That(r2, Is.TypeOf <HttpNotFoundResult>());
            Assert.That(r3, Is.TypeOf <HttpNotFoundResult>());
        }
Beispiel #14
0
        public void Test_Edit()
        {
            HotelRoomViewModel t = new HotelRoomViewModel()
            {
                Size = 2,
                Type = HotelRoomType.Workroom
            };
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    tr = new HotelRoomRepository(c);
            HotelRoomController     tc = new HotelRoomController(tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Staff);
            tc.ControllerContext = ccMock.Object;

            tc.Create(t);
            t.Size = 5;
            tc.Edit(t);
            Assert.AreEqual(tr.Find(t.Id).Size, 5);
            tr.Remove(t);
        }
Beispiel #15
0
        public void Test_Dispose()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    tr = new HotelRoomRepository(c);
            HotelRoomController     tc = new HotelRoomController(tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Staff);
            tc.ControllerContext = ccMock.Object;

            tc.Dispose();
            InvalidOperationException e = new InvalidOperationException("Wrong exception");

            try
            {
                tc.Details(1);
            }
            catch (InvalidOperationException exception)
            {
                e = exception;
            }
            Assert.AreEqual(e.Message, "The operation cannot be completed because the DbContext has been disposed.");
        }
Beispiel #16
0
 public HotelRoomServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance <ILocalizedResourceServices>();
     _hotelRoomRepository       = new HotelRoomRepository(entities);
 }
Beispiel #17
0
 public HotelRoomServices(PXHotelEntities entities)
 {
     _localizedResourceServices = HostContainer.GetInstance<ILocalizedResourceServices>();
     _hotelRoomRepository = new HotelRoomRepository(entities);
 }