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}")); } }
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); }
public IActionResult UpdateSystem(string id) { return(View(nameof(UpdateSystem), systemLogic.GetSystem(id))); }