Exemple #1
0
        public IActionResult AddSystem(Models.System s)
        {
            s.SystemID = Guid.NewGuid().ToString();

            systemLogic.AddSystem(s);
            return(RedirectToAction(nameof(ListSystem)));
        }
        public void TestGetSystem()
        {
            Mock <IRepository <Planet> >        planetRepo = new Mock <IRepository <Planet> >();
            Mock <IRepository <Star> >          starRepo   = new Mock <IRepository <Star> >();
            Mock <IRepository <Models.System> > systemRepo = new Mock <IRepository <Models.System> >();

            systemRepo.Setup(r => r.Read(It.IsAny <string>())).Returns(new Models.System()
            {
                SystemID = "TEST_ID"
            });
            SystemLogic logic = new SystemLogic(planetRepo.Object, starRepo.Object, systemRepo.Object);

            Models.System result = logic.GetSystem("TEST_ID");

            Assert.That(result, Is.EqualTo(new Models.System()
            {
                SystemID = "TEST_ID"
            }));
            systemRepo.Verify(r => r.Read(It.IsAny <string>()), Times.Once);
        }
Exemple #3
0
        public IActionResult UpdateSystem(Models.System s)
        {
            systemLogic.UpdateSystem(s.SystemID, s);

            return(View(nameof(ListSystem), systemLogic.GetAllSystem()));
        }
Exemple #4
0
        public IActionResult FillWithData()
        {
            if (filled)
            {
                //1. system

                Models.System sys1 = new Models.System()
                {
                    SystemID = Guid.NewGuid().ToString(), Name = "Illinium", SectorName = "B-123"
                };
                systemLogic.AddSystem(sys1);

                // 1. star
                Star s1 = new Star()
                {
                    StarID = Guid.NewGuid().ToString(), Name = "Galo", Age = 1000000, StarType = StarType.Red_Dwarfs, SystemID = sys1.SystemID
                };
                starLogic.AddStar(s1);

                Planet p1 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Kepler-6543B2", Habitable = true, PlanetType = PlanetType.Terran, Population = 10, StarID = s1.StarID
                };
                planetLogic.AddPlanet(p1);
                Planet p2 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Branco", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s1.StarID
                };
                planetLogic.AddPlanet(p2);
                Planet p3 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Elizabeth", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s1.StarID
                };
                planetLogic.AddPlanet(p3);
                Planet p4 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Gemini-65422A", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s1.StarID
                };
                planetLogic.AddPlanet(p4);
                Planet p5 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Pisces-493294", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s1.StarID
                };
                planetLogic.AddPlanet(p5);

                //2. star
                Star s2 = new Star()
                {
                    StarID = Guid.NewGuid().ToString(), Name = "Re", Age = 1000000000, StarType = StarType.Yellow_Dwarfs, SystemID = sys1.SystemID
                };
                starLogic.AddStar(s2);
                Planet p6 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Kepler-6543B2", Habitable = true, PlanetType = PlanetType.Terran, Population = 0, StarID = s2.StarID
                };
                planetLogic.AddPlanet(p6);
                Planet p7 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Branco", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s2.StarID
                };
                planetLogic.AddPlanet(p7);
                Planet p8 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Elizabeth", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s2.StarID
                };
                planetLogic.AddPlanet(p8);
                Planet p9 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Gemini-65422A", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s2.StarID
                };
                planetLogic.AddPlanet(p9);
                Planet p10 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Pisces-493294", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s2.StarID
                };
                planetLogic.AddPlanet(p10);

                //3. star

                Star s3 = new Star()
                {
                    StarID = Guid.NewGuid().ToString(), Name = "Draco", Age = 56500000, StarType = StarType.Orange_Dwarfs, SystemID = sys1.SystemID
                };
                starLogic.AddStar(s3);

                Planet p11 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Kepler-6543B2", Habitable = true, PlanetType = PlanetType.Terran, Population = 0, StarID = s3.StarID
                };
                planetLogic.AddPlanet(p11);
                Planet p12 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Branco", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s3.StarID
                };
                planetLogic.AddPlanet(p12);
                Planet p13 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Elizabeth", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s3.StarID
                };
                planetLogic.AddPlanet(p13);
                Planet p14 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Gemini-65422A", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s3.StarID
                };
                planetLogic.AddPlanet(p14);
                Planet p15 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Pisces-493294", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s3.StarID
                };
                planetLogic.AddPlanet(p15);

                //2. system
                Models.System sys2 = new Models.System()
                {
                    SystemID = Guid.NewGuid().ToString(), Name = "Scorpius", SectorName = "B-125"
                };
                systemLogic.AddSystem(sys2);
                ;
                //4. star sys 2
                Star s4 = new Star()
                {
                    StarID = Guid.NewGuid().ToString(), Name = "Leo", Age = 1000000, StarType = StarType.Red_Dwarfs, SystemID = sys2.SystemID
                };
                starLogic.AddStar(s4);
                Planet p17 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Branco", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s4.StarID
                };
                planetLogic.AddPlanet(p17);
                Planet p18 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Elizabeth", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s4.StarID
                };
                planetLogic.AddPlanet(p18);
                Planet p19 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Gemini-65422A", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s4.StarID
                };
                planetLogic.AddPlanet(p19);
                Planet p20 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Pisces-493294", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s4.StarID
                };
                planetLogic.AddPlanet(p20);

                //5. star sys 2

                Star s5 = new Star()
                {
                    StarID = Guid.NewGuid().ToString(), Name = "Pegasus", Age = 1000000000, StarType = StarType.Yellow_Dwarfs, SystemID = sys2.SystemID
                };
                starLogic.AddStar(s5);
                Planet p21 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Kepler-6543B2", Habitable = true, PlanetType = PlanetType.Terran, Population = 0, StarID = s5.StarID
                };
                planetLogic.AddPlanet(p21);
                Planet p22 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Branco", Habitable = false, PlanetType = PlanetType.Superterran, Population = 0, StarID = s5.StarID
                };
                planetLogic.AddPlanet(p22);
                Planet p23 = new Planet()
                {
                    PlanetID = Guid.NewGuid().ToString(), Name = "Elizabeth", Habitable = false, PlanetType = PlanetType.Jovian, Population = 0, StarID = s5.StarID
                };
                planetLogic.AddPlanet(p23);

                filled = false;
            }

            return(RedirectToAction(nameof(Index)));
        }
 public void UpdateSystem(string ID, Models.System newitem)
 {
     systemRepo.Update(ID, newitem);
 }
        //crud methods

        public void AddSystem(Models.System item)
        {
            this.systemRepo.Add(item);
        }