public ICommandResult Handle(GetFlowCommand command) { ICommandResult result = new GetFlowCommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.Flow, command.RequestHost }, "FlowCommandHandler.Handle(Get)"); try { if (_flowRepository.CheckExists(command.Flow)) { Flow flow = _flowRepository.Get(command.Flow); if (flow != null) { result = new GetFlowCommandResult(200, flow.Owner, flow.OwnerType, flow.Object, flow.CreationDate, flow.Path); } } else if (_flowRepository.Valid) { result = new GetFlowCommandResult(400, new Notification("Flow", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.Flow, command.RequestHost }, e); } return(result); }
public void GetFlowCommand_WhenCreated_TheIdentifierIsCorrect() { //Act Command command = new GetFlowCommand(); //Assert Assert.AreEqual('F', command.Identifier); }
public void GetFlowResponse_WhenConstructed_FlowValueIsParsedCorrectly() { //Arrange GetFlowCommand command = new GetFlowCommand(); byte[] data = ResponseHelper.AppendChecksum(new byte[] { 0x46, 0x01 }); //Act GetFlowResponse response = new GetFlowResponse(command, data); //Assert Assert.AreEqual(0x01, response.Flow, "The flow value is not correct."); }
public GetFlowCommandResult Get(Guid id) { GetFlowCommand command = new GetFlowCommand() { Flow = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { Flow = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); GetFlowCommandResult result = (GetFlowCommandResult)_flowHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { Flow = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }