public void InsertNinja() { //inicializa a injeção de dependencia //SimpleInjectorContainer.RegisterServices(); INinjaRepository ninjaRepository = new NinjaRepository(); INinjaClanRepository ninjaClanRepository = new NinjaClanRepository(); var ninjaClan = ninjaClanRepository.FindBy(nc => nc.ClanName == "Camargo's").FirstOrDefault(); if (ninjaClan != null) { Ninja ninja = new Ninja { NinjaName = "Bruna", DateCreated = DateTime.Now, DateModified = DateTime.Now, NinjaClanId = ninjaClan.Id }; if (!ninjaRepository.FindBy(n => n.NinjaName == ninja.NinjaName).Any()) { ninjaRepository.Add(ninja); ninjaRepository.Save(); } } }
public void GetNinjasBy() { INinjaRepository ninjaRepository = new NinjaRepository(); var ninjas = ninjaRepository.FindBy(ninja => ninja.NinjaClan.ClanName == "Camargo's"); Assert.IsNotNull(ninjas); Assert.AreEqual(ninjas.Count(), 2); foreach (var ninja in ninjas) { Console.WriteLine(ninja.NinjaName); } }
public void InsertNinjaWithoutClan() { //inicializa a injeção de dependencia SimpleInjectorContainer.RegisterServices(); INinjaRepository ninjaRepository = new NinjaRepository(); Ninja ninja = new Ninja { NinjaName = "Bolacha", DateCreated = DateTime.Now, DateModified = DateTime.Now }; if (!ninjaRepository.FindBy(n => n.NinjaName == ninja.NinjaName).Any()) { ninjaRepository.Add(ninja); ninjaRepository.Save(); } }