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);
        }
        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);
        }
示例#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 void Test_Create()
        {
            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name  = "Test_Creat",
                Alive = false
            };
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            ITamagotchiRepository   tr = new TamagotchiRepository(c);
            TamagotchiController    tc = new TamagotchiController(tr);
            var ccMock = new Mock <ControllerContext>();

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

            tc.Create(t);

            Assert.AreEqual(tr.Find(t.Id).ToModel(), t.ToModel());
        }