public async Task CorporationDeleteByKey() { var accrepo = AccountRepo; var skey = await accrepo.RegisterUser("*****@*****.**", "123"); var userid = await accrepo.CheckSession(skey); var repo = new CorporationRepo(AccountContextProvider, Logger, null); var keyRepo = new KeyInfoRepo(Logger, AccountContextProvider); var keyid1 = await keyRepo.AddKey(userid, 1, ""); var keyid2 = await keyRepo.AddKey(userid, 2, ""); var keyid3 = await keyRepo.AddKey(userid, 3, ""); // stage 1 var userData = new UserDataDto() { Pilots = new List <Pilot>(), Corporations = new Corporation[] { new Corporation() { EveId = 1, Name = "Corpo1", KeyInfoId = keyid1 }, new Corporation() { EveId = 2, Name = "Corpo2", KeyInfoId = keyid2 }, new Corporation() { EveId = 3, Name = "Corpo3", KeyInfoId = keyid3 } }.ToList(), Jobs = new List <Job>(), }; await repo.Update(userid, userData); var corporations = await repo.GetAll(userid); Assert.AreEqual(3, corporations.Count); await repo.DeleteByKey(keyid2); corporations = await repo.GetAll(userid); Assert.AreEqual(2, corporations.Count); Assert.IsTrue(corporations.Any(x => x.Name == "Corpo1")); Assert.IsTrue(corporations.Any(x => x.Name == "Corpo3")); await repo.DeleteByKey(keyid3); corporations = await repo.GetAll(userid); Assert.AreEqual(1, corporations.Count); Assert.IsTrue(corporations.Any(x => x.Name == "Corpo1")); }
public void LoadSubiews() { NewCorporation = new CorporationJson(); CorporationsList = new CorporationListJson { Data = CorporationRepo.GetAll() }; }
public async Task UpdateCorporations2() { var accrepo = AccountRepo; var skey = await accrepo.RegisterUser("*****@*****.**", "123"); var userid = await accrepo.CheckSession(skey); var repo = new CorporationRepo(AccountContextProvider, Logger, null); // stage 1 var userData = new UserDataDto() { Pilots = new List <Pilot>(), Corporations = new Corporation[] { new Corporation() { EveId = 1, Name = "Corpo1", KeyInfoId = 1 } }.ToList(), Jobs = new List <Job>(), }; await repo.Update(userid, userData); var corporations = await repo.GetAll(userid); Assert.AreEqual(1, corporations.Count); Assert.AreEqual("Corpo1", corporations.First().Name); // stage 2 var userData2 = new UserDataDto() { Pilots = new List <Pilot>(), Corporations = new Corporation[] { }.ToList(), Jobs = new List <Job>(), }; await repo.Update(userid, userData2); corporations = await repo.GetAll(userid); Assert.AreEqual(0, corporations.Count); }
public async Task UpdatePilotsAndCorporations2() { var accrepo = AccountRepo; var skey = await accrepo.RegisterUser("*****@*****.**", "123"); var userid = await accrepo.CheckSession(skey); var repo = new CorporationRepo(AccountContextProvider, Logger, null); var notificationRepo = new NotificationRepo(AccountContextProvider, Logger); var skillRepo = new SkillRepo(AccountContextProvider, Logger, notificationRepo); var pilotrepo = new PilotRepo(AccountContextProvider, Logger, null); var corporepo = new CorporationRepo(AccountContextProvider, Logger, null); // stage 1 var userData = new UserDataDto() { Pilots = new Pilot[] { new Pilot() { EveId = 1, KeyInfoId = 1, Name = "Pilot1", Skills = new List <Skill>() } }.ToList(), Corporations = new Corporation[] { new Corporation() { EveId = 1, Name = "Corpo1", KeyInfoId = 2 } }.ToList(), Jobs = new List <Job>(), }; await pilotrepo.Update(userid, userData); await corporepo.Update(userid, userData); var pilots = await pilotrepo.GetAll(userid); Assert.AreEqual(1, pilots.Count); Assert.AreEqual("Pilot1", pilots.First().Name); var corporations = await corporepo.GetAll(userid); Assert.AreEqual(1, corporations.Count); Assert.AreEqual("Corpo1", corporations.First().Name); // stage 2 var userData2 = new UserDataDto() { Pilots = new Pilot[] { }.ToList(), Corporations = new Corporation[] { }.ToList(), Jobs = new List <Job>(), }; await pilotrepo.Update(userid, userData2); await corporepo.Update(userid, userData2); pilots = await pilotrepo.GetAll(userid); Assert.AreEqual(0, pilots.Count); corporations = await corporepo.GetAll(userid); Assert.AreEqual(0, corporations.Count); // No notifications expected var notifications = await notificationRepo.GetAll(userid); Assert.AreEqual(0, notifications.Count); }