private static JobStatusUpdate CreateUpdateRequest(int workOrderId, RepairsApi.V2.Generated.WorkElement workElement)
 {
     return(new Helpers.StubGeneration.Generator <JobStatusUpdate>()
            .AddJobStatusUpdateGenerators()
            .AddValue(JobStatusUpdateTypeCode.Variation_80, (JobStatusUpdate jsu) => jsu.TypeCode)
            .AddValue(workOrderId.ToString(), (JobStatusUpdate jsu) => jsu.RelatedWorkOrderReference.ID)
            .AddValue(workElement, (JobStatusUpdate jsu) => jsu.MoreSpecificSORCode)
            .AddValue("comments", (JobStatusUpdate jsu) => jsu.Comments)
            .Generate());
 }
        private async Task <HttpStatusCode> UpdateSorCodes(int workOrderId, Action <JobStatusUpdate> interceptor = null)
        {
            var tasks = await GetTasks(workOrderId);

            RepairsApi.V2.Generated.WorkElement workElement = TransformTasksToWorkElement(tasks);

            return(await UpdateJob(workOrderId, jsu =>
            {
                jsu.MoreSpecificSORCode = workElement;
                interceptor?.Invoke(jsu);
            }));
        }
 private static void AddRateScheduleItem(RepairsApi.V2.Generated.WorkElement workElement, string code, int quantity, string id = null)
 {
     workElement.RateScheduleItem.Add(new RateScheduleItem
     {
         Id         = id,
         CustomCode = code,
         CustomName = "test code",
         Quantity   = new Quantity
         {
             Amount = new double[]
             {
                 quantity
             }
         }
     });
 }
        public async Task UpdateSorCodes()
        {
            // Arrange
            string expectedCode = "expectedCode_UpdateWorkOrder";

            AddTestCode(expectedCode);
            var result = await CreateWorkOrder();

            var originalTasks = await GetTasks(result.Id);

            RepairsApi.V2.Generated.WorkElement workElement = TransformTasksToWorkElement(originalTasks);
            AddRateScheduleItem(workElement, expectedCode, 10);
            JobStatusUpdate request = CreateUpdateRequest(result.Id, workElement);

            // Act
            var code = await Post("/api/v2/jobStatusUpdate", request);

            var newTasks = await GetTasks(result.Id);

            // Assert
            code.Should().Be(HttpStatusCode.OK);
            newTasks.Count().Should().Be(originalTasks.Count() + 1);
        }