private void TrickleDownTrustWorthiness(DrillSiteModel drillSite, DepthReadingModel currentReading, int nRecordsRequired) { var index = drillSite.DepthReadings.OrderBy(x => x.Id).IndexOf(currentReading); // starting index is the current index - the number of records necessary for the query // e.g. if we need to query 3 records and current index is 35, then start index would be 32 var indexOfFirstRequiredReading = Math.Max(0, index - nRecordsRequired); var indexToUpdate = index - indexOfFirstRequiredReading; var affectedReadings = drillSite.DepthReadings.OrderBy(x => x.Id).Skip(indexOfFirstRequiredReading).Take(nRecordsRequired * 2 + 1).ToList(); DrillSiteService.UpdateReadingsTrustworthiness(affectedReadings, indexToUpdate); }
public void TestUpdateReadingsTrustworthiness() { var config = new DrillConfigModel(5, 3, 1, 5); var readings = new List <DepthReadingModel>() { new DepthReadingModel(5, 150, 100), // avg dip = - last azimuth = - - trustworthy new DepthReadingModel(4, 145.01, 100), //avg dip = 5 last azimuth = 150 - trustworthy new DepthReadingModel(3, 142, 100), // avg dip = 4.5 last azimuth = ~145 - trustworthy new DepthReadingModel(5, 139, 100), // avg dip = 4 last azimuth = 142 - trustworthy new DepthReadingModel(5, 135, 100), // avg dip = 4.25 last azimuth = 139 - trustworthy new DepthReadingModel(1, 137, 100), // avg dip = 4.4 last azimuth = 135 - not trustworthy new DepthReadingModel(1, 134, 100), // avg dip = 3.6 last azimuth = 137 - trustworthy new DepthReadingModel(1, 120, 100), // avg dip = 3 last azimuth = 134 - not trustworthy new DepthReadingModel(2, 118, 100), // avg dip = 2.6 last azimuth = 120 - trustworthy new DepthReadingModel(3, 150, 100), // avg dip = 2 last azimuth = 120 - not trustworthy }; var expectedReadings = new List <DepthReadingModel>() { new DepthReadingModel(5, 150, 100), // avg dip = - last azimuth = - - trustworthy new DepthReadingModel(4, 145, 100), // avg dip = 5 last azimuth = 150 - trustworthy new DepthReadingModel(3, 140, 100), // avg dip = 4.5 last azimuth = 145 - trustworthy new DepthReadingModel(5, 139, 100), // avg dip = 4 last azimuth = 140 - trustworthy new DepthReadingModel(5, 135, 100), // avg dip = 4.25 last azimuth = 139 - trustworthy new DepthReadingModel(1, 137, 0.0), // avg dip = 4.4 last azimuth = 135 - not trustworthy new DepthReadingModel(1, 134, 100), // avg dip = 3.6 last azimuth = 137 - trustworthy new DepthReadingModel(1, 120, 0.0), // avg dip = 3 last azimuth = 134 - not trustworthy new DepthReadingModel(2, 118, 100), // avg dip = 2.6 last azimuth = 120 - trustworthy new DepthReadingModel(3, 150, 0.0), // avg dip = 2 last azimuth = 120 - not trustworthy }; // test not equal where trustworthness is expected to be false for (var i = 0; i < readings.Count; i++) { if (!expectedReadings[i].IsTrustworthy) { Assert.AreNotEqual(expectedReadings[i].IsTrustworthy, readings[i].IsTrustworthy); } } DrillSiteService.UpdateReadingsTrustworthiness(readings, 0, config); for (var i = 0; i < readings.Count; i++) { Assert.AreEqual(expectedReadings[i].IsTrustworthy, readings[i].IsTrustworthy); } }