public Task <WorksOrderListResponse> CreateRepairWithOrderAsync(NewRepairTasksRequest repairRequest)
        {
            var response = new WorksOrderListResponse
            {
                Success        = true,
                WorksOrderList = new List <WorksOrderDto>
                {
                    new WorksOrderDto
                    {
                        RepairRequestReference = "123456",
                        OrderReference         = "987654  ",
                        PropertyReference      = "00000320   ",
                        SupplierReference      = "000000127 "
                    }
                }.ToArray()
            };

            switch (repairRequest.RepairRequest.PropertyRef)
            {
            case "123456890":
                return(Task.Run(() => new WorksOrderListResponse
                {
                    Success = false,
                    WorksOrderList = new List <WorksOrderDto>().ToArray()
                }));

            case "00000320":
                return(Task.Run(() => response));

            default:
                return(Task.Run(() => new WorksOrderListResponse
                {
                    Success = true,
                    WorksOrderList = new List <WorksOrderDto>().ToArray()
                }));
            }
        }
        public async Task create_repair_with_work_order_returns_a_created_repair_response_object_with_orders_included()
        {
            var mockLogger = new Mock <ILoggerAdapter <RepairsActions> >();
            var request    = new RepairRequest
            {
                ProblemDescription = "tap leaking",
                Priority           = "N",
                PropertyReference  = "00000320",
                Contact            = new RepairRequestContact
                {
                    Name            = "Test",
                    TelephoneNumber = "0123456789"
                },
                WorkOrders = new List <WorkOrder>
                {
                    new WorkOrder
                    {
                        SorCode = "20090190"
                    }
                }
            };

            var repairRequest = new NewRepairTasksRequest
            {
                RepairRequest = new RepairRequestInfo
                {
                    PropertyRef = request.PropertyReference,
                    Priority    = request.Priority,
                    Problem     = request.ProblemDescription
                },
                TaskList = new List <RepairTaskInfo>
                {
                    new RepairTaskInfo
                    {
                        JobCode           = "12345678",
                        PropertyReference = "00000320",
                    }
                }.ToArray()
            };
            var fakeRepairService = new Mock <IHackneyRepairsService>();
            var response          = new WorksOrderListResponse
            {
                Success        = true,
                WorksOrderList = new List <WorksOrderDto>
                {
                    new WorksOrderDto
                    {
                        RepairRequestReference = "123456",
                        OrderReference         = "987654",
                        PropertyReference      = "00000320",
                        SupplierReference      = "00000127"
                    }
                }.ToArray()
            };
            var tasksListResponse = new TaskListResponse
            {
                Success  = true,
                TaskList = new List <RepairTaskDto>
                {
                    new RepairTaskDto
                    {
                        WorksOrderReference = "987654",
                        SupplierReference   = "00000127",
                        JobCode             = "12345678"
                    }
                }.ToArray()
            };

            fakeRepairService.Setup(service => service.CreateRepairWithOrderAsync(repairRequest))
            .ReturnsAsync(response);
            fakeRepairService.Setup(service => service.UpdateRequestStatus("123456")).ReturnsAsync(true);

            fakeRepairService.Setup(service => service.GetRepairTasksAsync(It.IsAny <RepairRefRequest>()))
            .ReturnsAsync(tasksListResponse);

            var fakeRequestBuilder = new Mock <IHackneyRepairsServiceRequestBuilder>();

            fakeRequestBuilder.Setup(builder => builder.BuildNewRepairTasksRequest(request)).Returns(repairRequest);
            fakeRequestBuilder.Setup(builder => builder.BuildRepairRequest("123456")).Returns(new RepairRefRequest());

            var repairsActions = new RepairsActions(fakeRepairService.Object, fakeRequestBuilder.Object, mockLogger.Object);
            var result         = await repairsActions.CreateRepair(request);

            var workOrders = new object[1];

            workOrders[0] = new { workOrderReference = "987654", sorCode = "12345678", supplierReference = "00000127" };
            var response1 = new
            {
                repairRequestReference = "123456",
                propertyReference      = "00000320",
                problemDescription     = "tap leaking",
                priority   = "N",
                contact    = new { name = "Test", telephoneNumber = "0123456789" },
                workOrders = workOrders
            };

            Assert.Equal(JsonConvert.SerializeObject(response1), JsonConvert.SerializeObject(result));
        }