public UnitTest1() { kamerRepository = new KamerRepository(); foreach (var item in kamerRepository.GetAll()) { kamerRepository.Delete(item); } tamagotchiRepository = new TamagotchiRepository(); foreach (var item in tamagotchiRepository.GetAll()) { tamagotchiRepository.Delete(item); } kamer = new HotelKamer { Id = 0, KamerType = "GameKamer", HoeveelheidBedden = 3 }; kamerNotFree = new HotelKamer { Id = 1, KamerType = "RustKamer", HoeveelheidBedden = 5, }; tama = new Tamagotchi { Id = 0, Naam = "Esper", Centjes = 100, Leeftijd = 0, Level = 0, Dood = false, Gezondheid = 100, Kleur = "Zwart", Verveling = 0 }; tama2 = new Tamagotchi { Id = 1, Naam = "Kees", Centjes = 100, Leeftijd = 0, Level = 0, Dood = false, Gezondheid = 100, Kleur = "Zwart", Verveling = 0 }; }
public void Test_DeleteConfirmed() { TamagotchiViewModel t = new TamagotchiViewModel() { Name = "Test_Remov", 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); tc.DeleteConfirmed(t.Id); Assert.IsFalse(tr.GetAll().Contains(t)); }
// GET: Tamagotchi public ActionResult Index() { List <TamagotchiVM> tamagotchisVM = _tamagotchiRepository.GetAll().Select(t => new TamagotchiVM(t)).ToList(); return(View(tamagotchisVM)); }