Hello! I am trying some unit testing using the guide on regression testing (https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Regression-Testing)
Part of my addin, runs a closest facility algorithm. I'm using SDK to run the geoprocess "MakeClosestFacilityAnalysisLayer".
When I run it normally using the UI, it all works perfectly.
When I'm running it using regression testing, the geoprocess is successful with no errors/warnings, however, the Network Analysis Layer is not loaded to my active map. I have set an active map programmatically, and I have confirmed that the Closest Facility feature dataset is created in my default gdb, however, since it's not loaded to the map, I can't seem to actually load data to it or run it.
internal static async Task<string> MakeAnalysisLayer(string network, string layer_name, ClosestFacilitySettings settings)
{
string actual_layer_name = layer_name;
int i = 1;
while (MapView.Active.Map.FindLayers(actual_layer_name).Count > 0)
{
actual_layer_name = layer_name + "_" + i.ToString();
i++;
}
var env = Geoprocessing.MakeEnvironmentArray(workspace: Project.Current.DefaultGeodatabasePath);
var MakeClosestFacilityAnalysisLayerParameters = Geoprocessing.MakeValueArray(
network,
actual_layer_name,
settings.travel_mode,
settings.travel_direction.ToString(),
settings.cutoff,
settings.numberOfFacilities
);
var mcfalResult = await Geoprocessing.ExecuteToolAsync("MakeClosestFacilityAnalysisLayer", MakeClosestFacilityAnalysisLayerParameters, env, flags: GPExecuteToolFlags.AddOutputsToMap);
return mcfalResult.ReturnValue;
}
Using the debugger, I'm seeing identical parameters, env values, network etc. The only difference is that the result is not loaded to the map.
I can't seem to fix it or find a workaround to make it work, not even a "hacky" one. Is this intended behavior, and if so, what's the proper way to do what I'm trying to do?