Exemple #1
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());
        }
Exemple #3
0
 public void SetChanged(TamagotchiViewModel entity)
 {
     _database.SetChanged(entity.ToModel());
     _database.SaveChanges();
 }
Exemple #4
0
 public void Remove(TamagotchiViewModel entity)
 {
     _database.Tamagotchi.Remove(entity.ToModel());
     _database.SaveChanges();
 }