public void update_a_corporation() { //Create corporation Connection one = new Connection(); CorporationRepo repo = new CorporationRepo(new Connection()); CorporationModel corporation = new CorporationModel(); corporation.name = "name"; corporation.email = "email"; corporation.zip = "3434-kj"; corporation.address = "address"; int id = repo.store(corporation); corporation.id = id; //Give corporation a new name corporation.name = "new name!"; repo.update(corporation); one.Connect(); SqlCommand sqlCommand = new SqlCommand("select * from corporation where name = 'new name!'", one.getConnection()); SqlDataReader reader = sqlCommand.ExecuteReader(); Assert.AreEqual(true, reader.HasRows); one.disConnect(); repo.destroy(id); }
public void LoadSubiews() { NewCorporation = new CorporationJson(); CorporationsList = new CorporationListJson { Data = CorporationRepo.GetAll() }; }
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 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 void store_and_delete_a_corporation() { Connection one = new Connection(); Connection two = new Connection(); CorporationRepo repo = new CorporationRepo(new Connection()); //Create corporation CorporationModel corporation = new CorporationModel(); corporation.name = "name"; corporation.email = "email"; corporation.zip = "3434-kj"; corporation.address = "address"; int id = repo.store(corporation); one.Connect(); SqlCommand sqlCommand = new SqlCommand("select * from corporation where name = 'name' and email ='email' and zip = '3434-kj' and address = 'address'", one.getConnection()); SqlDataReader reader = sqlCommand.ExecuteReader(); Assert.AreEqual(true, reader.HasRows); one.disConnect(); repo.destroy(id); two.Connect(); //Delete corporation SqlCommand sqlCommandTwo = new SqlCommand("select * from corporation where name = 'name' and email ='email' and zip = '3434-kj' and address = 'address'", two.getConnection()); SqlDataReader readerTwo = sqlCommandTwo.ExecuteReader(); Assert.AreEqual(false, readerTwo.HasRows); one.disConnect(); }
public async Task SinglePilot() { // MicioGatto key long code = 3645238; string vcode = "sLOD3pSHwuzKtml3inm59qvVWHiKA3rULJY7KRsuWmmHrZ0c8qAZlftLDQIHvxBq"; var accrepo = AccountRepo; var skey = await accrepo.RegisterUser("*****@*****.**", "123"); var userid = await accrepo.CheckSession(skey); var keyRepo = new KeyInfoRepo(Logger, AccountContextProvider); await keyRepo.AddKey(userid, code, vcode); var pilotRepo = new PilotRepo(AccountContextProvider, Logger, EveApi); var corpoRepo = new CorporationRepo(AccountContextProvider, Logger, EveApi); var notificationRepo = new NotificationRepo(AccountContextProvider, Logger); var skillRepo = new SkillRepo(AccountContextProvider, Logger, notificationRepo); var skillInQueueRepo = new SkillInQueueRepo(AccountContextProvider, Logger); var evePilotDataService = new EvePilotDataService(keyRepo, EveApi, Logger, TypeNameDict); var backgroundUpdate = new BackgroundUpdate(evePilotDataService, pilotRepo, corpoRepo, skillRepo, skillInQueueRepo); await backgroundUpdate.Update(userid); var pilots = await pilotRepo.GetAll(userid); Assert.AreEqual(1, pilots.Count); var p = pilots.First(); Assert.AreEqual("MicioGatto", p.Name); Assert.IsTrue(p.Skills.Count > 0); Assert.IsTrue(p.SkillsInQueue.Count > 0); Assert.IsTrue(p.Skills.Any(x => x.SkillName == "Interceptors")); }
void Handle(Input.SaveTrigger action) { CorporationRepo.Add(this.Title); }
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); }