コード例 #1
0
        public async Task JobsNotification()
        {
            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 pilotsRepo       = new PilotRepo(AccountContextProvider, Logger, null);
            var jobsRepo         = new JobRepo(AccountContextProvider, Logger, notificationRepo, pilotsRepo);

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

            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            var notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(1, notifications.Count);
            var n = notifications.First();

            Assert.AreEqual("Pilot1", n.Message);
            Assert.AreEqual("1 free manufacturing slots", n.Message2);
            await notificationRepo.Remove(n.NotificationId);

            // stage 2
            // Same info provided and expected no further notifications
            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count);
            var pilots = await pilotsRepo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
            Assert.AreEqual(1, pilots.First().FreeManufacturingJobsNofificationCount);

            // stage 3
            // First job started - still no notification - but notification flag shoud be reset
            var userData2 = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId                = 1,
                        KeyInfoId            = 1,
                        Name                 = "Pilot1",
                        Skills               = new List <Skill>(),
                        MaxManufacturingJobs = 1,
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new Job[]
                {
                    new Job()
                    {
                        IsManufacturing = true, Owner = "Pilot1"
                    }
                }.ToList(),
            };
            await pilotsRepo.Update(userid, userData2);

            await jobsRepo.Update(userid, userData2);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count());
            pilots = await pilotsRepo.GetAll(userid);

            Assert.AreEqual(1, pilots.Count);
            Assert.AreEqual(0, pilots.First().FreeManufacturingJobsNofificationCount);

            // stage 4
            // No running jobs - notification expected
            await pilotsRepo.Update(userid, userData);

            await jobsRepo.Update(userid, userData);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(1, notifications.Count());
            n = notifications.First();
            Assert.AreEqual("Pilot1", n.Message);
            Assert.AreEqual("1 free manufacturing slots", n.Message2);
            await notificationRepo.Remove(n.NotificationId);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public async Task SkillsNotificationLevelUp()
        {
            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);

            // stage 1 - skills firstly seen - no notification expected
            var userData = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId     = 1,
                        KeyInfoId = 1,
                        Name      = "Pilot1",
                        Skills    = new Skill[] { new Skill()
                                                  {
                                                      SkillName = "skilla", Level = 1
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skillb", Level = 2
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skill ", Level = 3
                                                  } }.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(3, skills.Count);

            var notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count());

            // stage 2 - level up
            var userData2 = new UserDataDto()
            {
                Pilots = new Pilot[]
                {
                    new Pilot()
                    {
                        EveId     = 1,
                        KeyInfoId = 1,
                        Name      = "Pilot1",
                        Skills    = new Skill[] { new Skill()
                                                  {
                                                      SkillName = "skilla", Level = 1
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skillb", Level = 2
                                                  }, new Skill()
                                                  {
                                                      SkillName = "skill ", Level = 4
                                                  } }.ToList(),
                    }
                }.ToList(),
                Corporations = new List <Corporation>(),
                Jobs         = new List <Job>(),
            };

            await pilotRepo.Update(userid, userData2);

            await skillRepo.Update(userid, userData2);

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

            Assert.AreEqual(3, skills.Count);

            notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(1, notifications.Count);
            var n = notifications.First(x => x.Message2.Contains("skill  4"));

            Assert.AreEqual("Pilot1", n.Message);
            Assert.AreEqual("skill  4 trained", n.Message2);
            await notificationRepo.Remove(n.NotificationId);
        }
コード例 #4
0
        public async Task UpdatePilots1()
        {
            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);


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

            await repo.Update(userid, userData);

            Assert.AreNotEqual(0, userData.Pilots[0].PilotId);

            var pilots = await repo.GetAll(userid);

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

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

            await repo.Update(userid, userData2);

            Assert.AreNotEqual(0, userData2.Pilots[0].PilotId);
            Assert.AreNotEqual(0, userData2.Pilots[1].PilotId);
            Assert.AreNotEqual(userData2.Pilots[0].PilotId, userData2.Pilots[1].PilotId);

            pilots = await repo.GetAll(userid);

            Assert.AreEqual(2, pilots.Count);
            Assert.AreEqual("Pilot2", pilots.First(x => x.Name == "Pilot2").Name);
            Assert.AreEqual("Pilot3", pilots.First(x => x.Name == "Pilot3").Name);

            // No notifications expected
            var notifications = await notificationRepo.GetAll(userid);

            Assert.AreEqual(0, notifications.Count);
        }