Пример #1
0
        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"));
        }
Пример #2
0
        public async Task AddKeyInfo()
        {
            var accrepo = AccountRepo;
            var skey    = await accrepo.RegisterUser("*****@*****.**", "123");

            var userid = await accrepo.CheckSession(skey);

            var repo = new KeyInfoRepo(Logger, AccountContextProvider);

            var keyinfoid1 = await repo.AddKey(userid, 1, "ala");

            var result = await repo.GetKeys(userid);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("ala", result.FirstOrDefault().VCode);

            var keyinfoid2 = await repo.AddKey(userid, 2, "kot");

            result = await repo.GetKeys(userid);

            Assert.AreEqual(2, result.Count);
            Assert.AreEqual("ala", result.First(x => x.KeyId == 1).VCode);
            Assert.AreEqual("kot", result.First(x => x.KeyId == 2).VCode);

            await repo.DeleteKey(keyinfoid1);

            result = await repo.GetKeys(userid);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("kot", result.FirstOrDefault().VCode);

            await repo.DeleteKey(keyinfoid2);

            result = await repo.GetKeys(userid);

            Assert.AreEqual(0, result.Count);
        }
Пример #3
0
        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"));
        }
Пример #4
0
        public async Task DeleteKey()
        {
            var accrepo = AccountRepo;
            var skey    = await accrepo.RegisterUser("*****@*****.**", "123");

            var userid = await accrepo.CheckSession(skey);

            var notificationRepo = new NotificationRepo(AccountContextProvider, Logger);
            var skillRepo        = new SkillRepo(AccountContextProvider, Logger, notificationRepo);
            var pilotRepo        = new PilotRepo(AccountContextProvider, Logger, null);
            var keyRepo          = new KeyInfoRepo(Logger, AccountContextProvider);

            long keyid1 = await keyRepo.AddKey(userid, 1, "");

            long keyid2 = await keyRepo.AddKey(userid, 2, "");

            // stage 1 - skills firstly seen - no notification expected
            var userData = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId     = 1,
                        KeyInfoId = keyid1,
                        Name      = "Pilot1",
                        Skills    = new Skill[] { new Skill()
                                                  {
                                                      SkillName = "skill", Level = 1
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skill", Level = 2
                                                  } }.ToList(),
                    },
                    new Pilot()
                    {
                        EveId     = 2,
                        KeyInfoId = keyid2,
                        Name      = "Pilot2",
                        Skills    = new Skill[] { new Skill()
                                                  {
                                                      SkillName = "skill", Level = 1
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skill", Level = 2
                                                  } }.ToList(),
                    },
                    new Pilot()
                    {
                        EveId     = 3,
                        KeyInfoId = keyid2,
                        Name      = "Pilot3",
                        Skills    = new Skill[] { new Skill()
                                                  {
                                                      SkillName = "skilla", Level = 1
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skilla", Level = 2
                                                  } }.ToList(),
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new List <Job>(),
            };

            await pilotRepo.Update(userid, userData);

            await skillRepo.Update(userid, userData);

            var skills = await skillRepo.GetForPilot(userData.Pilots[0].PilotId);

            Assert.AreEqual(2, skills.Count);

            await pilotRepo.DeleteByKey(keyid2);

            skills = await skillRepo.GetForPilot(userData.Pilots[0].PilotId);

            Assert.AreEqual(2, skills.Count);

            using (var ctx = AccountContextProvider.Context)
            {
                var c = ctx.Skills.Count(p => p.PilotId == userData.Pilots[1].PilotId);
                Assert.AreEqual(0, c);
                c = ctx.Skills.Count(p => p.PilotId == userData.Pilots[2].PilotId);
                Assert.AreEqual(0, c);
            }
        }
Пример #5
0
        public async Task PilotDeleteByKey()
        {
            var accrepo = AccountRepo;
            var skey    = await accrepo.RegisterUser("*****@*****.**", "123");

            var userid = await accrepo.CheckSession(skey);

            var notificationRepo = new NotificationRepo(AccountContextProvider, Logger);
            var skillRepo        = new SkillRepo(AccountContextProvider, Logger, notificationRepo);
            var repo             = new PilotRepo(AccountContextProvider, Logger, null);
            var keyRepo          = new KeyInfoRepo(Logger, AccountContextProvider);

            long keyid1 = await keyRepo.AddKey(userid, 1, "");

            long keyid2 = await keyRepo.AddKey(userid, 2, "");

            // stage 1
            var userData = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId     = 1,
                        KeyInfoId = keyid1,
                        Name      = "Pilot1",
                        Skills    = new List <Skill>()
                    },
                    new Pilot()
                    {
                        EveId     = 2,
                        KeyInfoId = keyid2,
                        Name      = "Pilot2",
                        Skills    = new List <Skill>()
                    },
                    new Pilot()
                    {
                        EveId     = 3,
                        KeyInfoId = keyid2,
                        Name      = "Pilot3",
                        Skills    = new List <Skill>()
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new List <Job>(),
            };

            await repo.Update(userid, userData);

            var pilots = await repo.GetAll(userid);

            Assert.AreEqual(3, pilots.Count);

            await repo.DeleteByKey(keyid2);

            pilots = await repo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
            Assert.AreEqual("Pilot1", pilots.First().Name);

            // delete using non existing key
            await repo.DeleteByKey(keyid1 + keyid2 + 1);

            pilots = await repo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
        }