Esempio n. 1
0
 public ActionResult <Models.System> GetSystem(string id)
 {
     try
     {
         var system = systemLogic.GetSystem(id);
         return(Ok(system));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, $"Internal server error : {ex}"));
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public IActionResult UpdateSystem(string id)
 {
     return(View(nameof(UpdateSystem), systemLogic.GetSystem(id)));
 }