Exemple #1
0
 private CrsTransformationResult CreateCrsTransformationResult(
     CrsCoordinate outputCoordinate,
     ICrsTransformationAdapter adapter,
     CrsCoordinate inputCoordinateNotUsedInThisTest
 ) {
     Exception exceptionNull = null;
     bool isSuccessTrue = true;
     return CrsTransformationResult._CreateCrsTransformationResult(
         inputCoordinateNotUsedInThisTest,
         outputCoordinate,
         exceptionNull,
         isSuccessTrue,
         adapter,
         CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List<CrsTransformationResult>())
     );
 }
Exemple #2
0
 public void TransformResult_ShouldReturnStatisticsObjectWithCorrectAverageAndMeanAndMaxDiffValues_WhenCreatingResultWithListOfSubresults() {
     // Both the setup code and the verify/assertion code for this test method 
     // is placed in a base class because it is reused from another test class.
     // The keyword "super" is used below to make that more obvious.
     
     CrsTransformationResult transformResult = CrsTransformationResult._CreateCrsTransformationResult(
         base.inputCoordinateNotUsedInStatisticsTest,
         base.outputCoordinateNotUsedInStatisticsTest,
         null,
         true,
         base.compositeAdapterForResultTest,
         CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(base.listOfSubresultsForStatisticsTest)
     );
     CrsTransformationResultStatistic crsTransformationResultStatistic = transformResult.CrsTransformationResultStatistic;
     base.AssertCrsTransformationResultStatistic(crsTransformationResultStatistic);
 }
Exemple #3
0
 // Lots of method in this test class creates a 
 // CrsTransformationResult with three of the six 
 // parameters being exactly the same.
 // For that reason this helper method is used,
 // i.e. to not duplicate the three 
 // parameters almost always being the same.
 private CrsTransformationResult CreateCrsTransformationResult(
     //CrsCoordinate inputCoordinate: ,
     CrsCoordinate outputCoordinate,
     Exception exceptionOrNull,
     bool isSuccess
     //crsTransformationAdapterResultSource: ICrsTransformationAdapter,
     //nullableCrsTransformationResultStatistic: CrsTransformationResultStatistic// = null
 ) {
     var transformResult = CrsTransformationResult._CreateCrsTransformationResult(
         inputCoordinate,
         outputCoordinate,
         exceptionOrNull,
         isSuccess,
         base.compositeAdapterForResultTest,
         CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(base.listOfSubresultsForStatisticsTest)
     );
     return transformResult;
 }
        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"
                                                                                            );
        }
 public void TransformResultStatistic_ShouldCalculateCorrectAverageAndMeanAndMaxDiffValues() {
     // Both the setup code and the verify/assertion code for this test method 
     // is placed in a base class because it is reused from another test class
     // The keyword "base" is not needed but used below to make that more obvious.
     
     CrsTransformationResultStatistic crsTransformationResultStatistic = CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(
         base.listOfSubresultsForStatisticsTest
     );
     // the above factory method is "internal" in the F# project 
     // but still can be used from this test project 
     // because of the following configuration in the F# core project:
     //<ItemGroup>
     //  <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
     //    <_Parameter1>Programmerare.CrsTransformations.Test</_Parameter1>
     //  </AssemblyAttribute>
     //</ItemGroup>
     
     base.AssertCrsTransformationResultStatistic(crsTransformationResultStatistic);
 }
        public void SetUp()
        {
            weightFactory = CrsTransformationAdapterWeightFactory.Create();

            crsTransformationAdapterCompositeFactory = CrsTransformationAdapterCompositeFactory.Create();
            double[] outputLatitudes =
            {
                59.1,
                59.2,
                59.3,
                59.4,
                59.6,
            };
            expectedMedianLatitude  = 59.3;
            expectedAverageLatitude = 59.32;

            double[] outputLongitudes =
            {
                18.2,
                18.3,
                18.4,
                18.8,
                18.9
            };
            expectedMedianLongitude  = 18.4;
            expectedAverageLongitude = 18.52;

            outputCoordinateWgs84ForImplementation_1 = CrsCoordinateFactory.CreateFromLatitudeLongitude(outputLatitudes[0], outputLongitudes[3]);
            outputCoordinateWgs84ForImplementation_2 = CrsCoordinateFactory.CreateFromLatitudeLongitude(outputLatitudes[2], outputLongitudes[1]);
            outputCoordinateWgs84ForImplementation_3 = CrsCoordinateFactory.CreateFromLatitudeLongitude(outputLatitudes[4], outputLongitudes[4]);
            outputCoordinateWgs84ForImplementation_4 = CrsCoordinateFactory.CreateFromLatitudeLongitude(outputLatitudes[1], outputLongitudes[0]);
            outputCoordinateWgs84ForImplementation_5 = CrsCoordinateFactory.CreateFromLatitudeLongitude(outputLatitudes[3], outputLongitudes[2]);
            outputCoordinates = new List <CrsCoordinate> {
                outputCoordinateWgs84ForImplementation_1,
                outputCoordinateWgs84ForImplementation_2,
                outputCoordinateWgs84ForImplementation_3,
                outputCoordinateWgs84ForImplementation_4,
                outputCoordinateWgs84ForImplementation_5
            };

            mock1 = new Mock <ICrsTransformationAdapter>();
            mock2 = new Mock <ICrsTransformationAdapter>();
            mock3 = new Mock <ICrsTransformationAdapter>();
            mock4 = new Mock <ICrsTransformationAdapter>();
            mock5 = new Mock <ICrsTransformationAdapter>();

            leafAdapterImplementation_1 = mock1.Object;
            leafAdapterImplementation_2 = mock2.Object;
            leafAdapterImplementation_3 = mock3.Object;
            leafAdapterImplementation_4 = mock4.Object;
            leafAdapterImplementation_5 = mock5.Object;

            inputCoordinateSweref99 = CrsCoordinateFactory.CreateFromYNorthingLatitudeAndXEastingLongitude(6580822.0, 674032.0, EpsgNumber.SWEDEN__SWEREF99_TM__3006);

            CrsTransformationResult leafResult1 = CrsTransformationResult._CreateCrsTransformationResult(
                inputCoordinateSweref99,
                outputCoordinateWgs84ForImplementation_1,
                null,
                true,
                leafAdapterImplementation_1,
                CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List <CrsTransformationResult>())
                );
            CrsTransformationResult leafResult2 = CrsTransformationResult._CreateCrsTransformationResult(
                inputCoordinateSweref99,
                outputCoordinateWgs84ForImplementation_2,
                null,
                true,
                leafAdapterImplementation_2,
                CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List <CrsTransformationResult>())
                );
            CrsTransformationResult leafResult3 = CrsTransformationResult._CreateCrsTransformationResult(
                inputCoordinateSweref99,
                outputCoordinateWgs84ForImplementation_3,
                null,
                true,
                leafAdapterImplementation_3,
                CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List <CrsTransformationResult>())
                );
            CrsTransformationResult leafResult4 = CrsTransformationResult._CreateCrsTransformationResult(
                inputCoordinateSweref99,
                outputCoordinateWgs84ForImplementation_4,
                null,
                true,
                leafAdapterImplementation_4,
                CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List <CrsTransformationResult>())
                );
            CrsTransformationResult leafResult5 = CrsTransformationResult._CreateCrsTransformationResult(
                inputCoordinateSweref99,
                outputCoordinateWgs84ForImplementation_5,
                null,
                true,
                leafAdapterImplementation_5,
                CrsTransformationResultStatistic._CreateCrsTransformationResultStatistic(new List <CrsTransformationResult>())
                );

            crsIdentifierWGS84 = CrsIdentifierFactory.CreateFromEpsgNumber(EpsgNumber.WORLD__WGS_84__4326);

            mock1.Setup(leaf => leaf.Transform(inputCoordinateSweref99, crsIdentifierWGS84)).Returns(leafResult1);
            mock2.Setup(leaf => leaf.Transform(inputCoordinateSweref99, crsIdentifierWGS84)).Returns(leafResult2);
            mock3.Setup(leaf => leaf.Transform(inputCoordinateSweref99, crsIdentifierWGS84)).Returns(leafResult3);
            mock4.Setup(leaf => leaf.Transform(inputCoordinateSweref99, crsIdentifierWGS84)).Returns(leafResult4);
            mock5.Setup(leaf => leaf.Transform(inputCoordinateSweref99, crsIdentifierWGS84)).Returns(leafResult5);

            //mock1.Setup(leaf => leaf.LongNameOfImplementation).Returns("1");
            //mock2.Setup(leaf => leaf.LongNameOfImplementation).Returns("2");
            //mock3.Setup(leaf => leaf.LongNameOfImplementation).Returns("3");
            //mock4.Setup(leaf => leaf.LongNameOfImplementation).Returns("4");
            //mock5.Setup(leaf => leaf.LongNameOfImplementation).Returns("5");
            mock1.Setup(leaf => leaf.AdapteeType).Returns(CrsTransformationAdapteeType.LEAF_DOT_SPATIAL_2_0_0_RC1);
            mock2.Setup(leaf => leaf.AdapteeType).Returns(CrsTransformationAdapteeType.LEAF_PROJ_NET_2_0_0);
            mock3.Setup(leaf => leaf.AdapteeType).Returns(CrsTransformationAdapteeType.LEAF_MIGHTY_LITTLE_GEODESY_1_0_2);
            // The type must be different but there are only three concrete types as above to use
            // but then instead can use the ones below (and the purpose of this enum is to use it as key in a dictionary/hashtable)
            mock4.Setup(leaf => leaf.AdapteeType).Returns(CrsTransformationAdapteeType.UNSPECIFIED_LEAF);
            mock5.Setup(leaf => leaf.AdapteeType).Returns(CrsTransformationAdapteeType.UNSPECIFIED);

            allLeafAdapters = new List <ICrsTransformationAdapter> {
                leafAdapterImplementation_1,
                leafAdapterImplementation_2,
                leafAdapterImplementation_3,
                leafAdapterImplementation_4,
                leafAdapterImplementation_5
            };
        }