public static Agents.AutoService.Models.Auto ConvertAuto(Entities.Auto auto) { var newAuto = new Agents.AutoService.Models.Auto() { Id = auto.Id == 0 ? new long?() : auto.Id, Kenteken = auto.Kenteken, KlantId = auto.KlantId == 0 ? new long?() : auto.KlantId, Type = auto.Type }; return(newAuto); }
public static Entities.Auto ConvertAuto(Agents.AutoService.Models.Auto auto) { var newAuto = new Entities.Auto() { Id = auto.Id.HasValue ? auto.Id.Value : 0, Kenteken = auto.Kenteken, KlantId = auto.KlantId.HasValue ? auto.KlantId.Value : 0, Type = auto.Type }; return(newAuto); }
public Entities.Auto AutoInvoeren(Entities.Auto auto) { using (IAutoServiceClient agent = new AutoServiceClient()) { agent.BaseUri = new Uri("http://jomaya-autoservice/"); //agent.BaseUri = new Uri("http://localhost:5003/"); var result = agent.PostCreateAuto(ObjectMapper.ConvertAuto(auto)); if (result is AutoService.Models.Auto) { return(ObjectMapper.ConvertAuto(result as AutoService.Models.Auto)); } else { throw new InvalidOperationException("Een fout is opgetreden bij de MicroService, " + result.ToString()); } } }
public void ToevoegenLevertEenViewResultEnCalledAutoServiceAgentTest() { // Arrange var agentMock = new Mock <IAutoServiceAgent>(MockBehavior.Strict); var auto = new Entities.Auto() { KlantId = 1, Kenteken = "AA-BB-11" }; var returnAuto = new Entities.Auto() { Id = 1, Type = "personenauto", KlantId = 1, Kenteken = "AA-BB-11" }; agentMock.Setup(agent => agent.AutoInvoeren(It.IsAny <Auto>())).Returns(returnAuto); var target = new AutoController(agentMock.Object); // Act var result = target.Toevoegen(auto); // Assert Assert.IsInstanceOfType(result, typeof(RedirectToActionResult)); agentMock.Verify(agent => agent.AutoInvoeren(It.IsAny <Auto>()), Times.Once()); }