public BusinessLayerTests() { var options = SqliteInMemory.CreateOptions <ApplicationContext>(); context = new ApplicationContext(options); context.Database.EnsureCreated(); // Seed Inventory content context.SeedItemTypes(); context.SeedItemImages(); // Seed Monster content context.SeedMonsterModels(); context.SeedMonsterNames(); context.SeedMonsterTitles(); inventoryRepository = new InventoryRepository(context); inventoryService = new InventoryService(inventoryRepository); playerRepository = new PlayerRepository(context); playerService = new PlayerService(playerRepository); monsterRepository = new MonsterRepository(context); monsterService = new MonsterService(monsterRepository); knightRepository = new KnightRepository(context); landmarkRepository = new LandmarkRepository(context); landmarkService = new LandmarkService(landmarkRepository, knightRepository); }
public void ShouldNotAddNullKnight() { KnightRepository.Add(null); var knights = _context.Knights.ToList(); Assert.AreEqual(0, knights.Count()); }
public ActionResult DeleteConfirmed(int id) { MessageType messageType = KnightRepository.Remove(id); if (messageType == MessageType.Success) { return(RedirectToAction("Index")); } return(HttpNotFound()); }
// // GET: /Knight/Details/5 public ActionResult Details(int id = 0) { Knight knight = KnightRepository.FindById(id); if (knight == null) { return(HttpNotFound()); } return(View(knight)); }
// // GET: /Knight/Edit/5 public ActionResult Edit(int id = 0) { Knight knight = KnightRepository.FindById(id); if (knight == null) { return(RedirectToAction("Index")); } return(View(knight)); }
public void CanAddKnight() { Knight expected = PersonFactory.CreateKnight("Arthur"); KnightRepository.Add(expected); var knights = _context.Knights.ToList(); Assert.AreEqual(1, knights.Count()); Assert.AreEqual(expected, knights.FirstOrDefault()); }
public ActionResult Create(Knight knight) { if (ModelState.IsValid && knight != null) { KnightRepository.Add(knight); return(RedirectToAction("Index")); } ViewBag.Message = Messages.Error_Field_Check; ViewBag.Title = PersonResource.Title_CreateKnight; return(View(knight)); }
public void RetrieveKnightById() { Knight expected = PersonFactory.CreateKnight("Arthur"); _context.Knights.Add(expected); _context.SaveChanges(); Knight actual = KnightRepository.FindById(expected.Id); ; Assert.AreEqual(expected, actual); }
// // GET: /Knight/Delete/5 public ActionResult Delete(int id = 0) { if (id > 0) { Knight knight = KnightRepository.FindById(id); if (knight != null) { return(View(knight)); } } return(HttpNotFound()); }
public void KnightShouldNotUseBadIdToDelete() { Knight expected1 = PersonFactory.CreateKnight("Arthur"); Knight expected2 = PersonFactory.CreateKnight("Lancelot"); _context.Knights.Add(expected1); _context.Knights.Add(expected2); _context.SaveChanges(); KnightRepository.Remove(6); var knights = _context.Knights.ToList(); Assert.AreEqual(2, knights.Count()); }
public void KnightCanBeUpdated() { Knight expected = PersonFactory.CreateKnight("Arthur"); _context.Knights.Add(expected); _context.SaveChanges(); expected.Email = "*****@*****.**"; expected.FirstName = "Arthur Junior"; MessageType message = KnightRepository.Update(expected); Assert.AreEqual(MessageType.Success, message); Assert.AreEqual(expected, _context.Knights.Find(expected.Id)); }
public void CanDeleteKnight() { Knight expected1 = PersonFactory.CreateKnight("Arthur"); Knight expected2 = PersonFactory.CreateKnight("Lancelot"); _context.Knights.Add(expected1); _context.Knights.Add(expected2); _context.SaveChanges(); KnightRepository.Remove(expected1.Id); var knights = _context.Knights.ToList(); Assert.AreEqual(1, knights.Count()); Assert.AreEqual(expected2, knights.FirstOrDefault()); }
public ActionResult Edit(Knight knight) { if (knight == null) { return(HttpNotFound()); } if (ModelState.IsValid) { MessageType messageType = KnightRepository.Update(knight); if (messageType == MessageType.Success) { return(RedirectToAction("Index")); } } return(View(knight)); }
public virtual void TestInitialize() { LoadContext(); KnightRepository = new KnightRepository(_context); }
public LandmarkService(LandmarkRepository landmarkRepository, KnightRepository knightRepository) { this.landmarkRepo = landmarkRepository; this.knightRepo = knightRepository; }
public void KnightCanNotEditANullKnight() { MessageType message = KnightRepository.Update(null); Assert.AreEqual(MessageType.Error, message); }
public void ShouldNotRetrieveKnightWithId0() { Knight actual = KnightRepository.FindById(0); Assert.IsNull(actual); }
// // GET: /Knight/ public ActionResult Index() { return(View(KnightRepository.FindAll())); }
public KnightController() { KnightRepository = new KnightRepository(_context); }
public KnightsService(KnightRepository repo) { _repo = repo; }