public void CreateCompositeStrategyWeightedAverage_whenAllWeightsArePositive__shouldNotThrowException() { List <CrsTransformationAdapterWeight> weightedCrsTransformationAdapters = new List <CrsTransformationAdapterWeight> { weightFactory.CreateFromInstance( new CrsTransformationAdapterMightyLittleGeodesy(), 1 // null is not possible (compiling error) which is good ! ) }; CompositeStrategyWeightedAverage compositeStrategyWeightedAverage = CompositeStrategyWeightedAverage._CreateCompositeStrategyWeightedAverage(weightedCrsTransformationAdapters); // (the above method is "internal" in the F# project but still available from here // because of "InternalsVisibleTo" configuration in the .fsproj file) // The main test of this test method is that the above create method does not throw an exception Assert.IsNotNull(compositeStrategyWeightedAverage); }
public void CalculateAggregatedResult_ShouldThrowException_WhenResultIsBasedOnLeafsNotBeingPartOfTheWeightedAverageAdapter() { CrsCoordinate coordinate = CrsCoordinateFactory.LatLon(59, 18); List <CrsTransformationResult> emptyListOfTransformationResults = new List <CrsTransformationResult>(); ICrsTransformationAdapter leafMightyLittleGeodesy = new CrsTransformationAdapterMightyLittleGeodesy(); List <CrsTransformationAdapterWeight> leafWeightsForOnlyMightyLittleGeodesy = new List <CrsTransformationAdapterWeight> { weightFactory.CreateFromInstance( leafMightyLittleGeodesy, 1 ) }; // The below type ICompositeStrategy is "internal" in the F# project but still available from here // because of "InternalsVisibleTo" configuration in the .fsproj file. ICompositeStrategy compositeStrategyWeightedAverageForOnlyMightyLittleGeodesy = CompositeStrategyWeightedAverage._CreateCompositeStrategyWeightedAverage(leafWeightsForOnlyMightyLittleGeodesy); // The above composite was created with only one leaf in the list ICrsTransformationAdapter leafDotSpatial = new CrsTransformationAdapterDotSpatial(); CrsTransformationResult crsTransformationResultProblem = new CrsTransformationResult( coordinate, // inputCoordinate irrelevant in this test so okay to use the same as the output coordinate, // outputCoordinate null, // exception true, // isSuccess leafDotSpatial, // crsTransformationAdapterResultSource, CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(emptyListOfTransformationResults) ); // The composite strategy used below was created with only MightyLittleGeodesy, // and therefore if the result (as below) would be based on "DotSpatial" // then there is a bug somewhere i.e. an exception is thrown // which is tested below InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => { compositeStrategyWeightedAverageForOnlyMightyLittleGeodesy._CalculateAggregatedResult( new List <CrsTransformationResult> { crsTransformationResultProblem }, // allResults coordinate, coordinate.CrsIdentifier, // crsIdentifier for OutputCoordinateSystem leafDotSpatial // SHOULD CAUSE EXCEPTION ! ); }, "The result adapter was not part of the weighted average composite adapter" ); }