3333using Numerics . Distributions ;
3434using System . Collections . Generic ;
3535using System . Linq ;
36+ using System . Xml . Linq ;
3637
3738namespace Data . PairedData
3839{
@@ -95,6 +96,18 @@ public void Test_ReadWriteXElement()
9596 Assert . IsTrue ( _dataset4 == newDataset4 ) ;
9697 }
9798
99+ [ TestMethod ]
100+ public void Test_ReadWriteXElement2 ( )
101+ {
102+
103+ string testEl = "<IntervalDistributions X_Strict=\" True\" Y_Strict=\" True\" X_Order=\" Ascending\" Y_Order=\" None\" Distribution=\" PertPercentile\" AllowDifferentDistributionTypes=\" False\" >\r \n <Ordinates>\r \n <UncertainOrdinate X=\" 4000\" >\r \n <Distribution Type=\" PertPercentile\" Percentile5th=\" 0\" Percentile50th=\" 0.10000000000000001\" Percentile95th=\" 0.5\" />\r \n </UncertainOrdinate>\r \n <UncertainOrdinate X=\" 8500\" >\r \n <Distribution Type=\" PertPercentile\" Percentile5th=\" 0.0050000000000000001\" Percentile50th=\" 0.5\" Percentile95th=\" 0.75\" />\r \n </UncertainOrdinate>\r \n <UncertainOrdinate X=\" 16000\" >\r \n <Distribution Type=\" PertPercentile\" Percentile5th=\" 0.01\" Percentile50th=\" 0.69999999999999996\" Percentile95th=\" 0.98999999999999999\" />\r \n </UncertainOrdinate>\r \n <UncertainOrdinate X=\" 30000\" >\r \n <Distribution Type=\" PertPercentile\" Percentile5th=\" 0.90000000000000002\" Percentile50th=\" 0.90000000000000002\" Percentile95th=\" 0.90000000000000002\" />\r \n </UncertainOrdinate>\r \n <UncertainOrdinate X=\" 40000\" >\r \n <Distribution Type=\" PertPercentile\" Percentile5th=\" 0.94999999999999996\" Percentile50th=\" 0.94999999999999996\" Percentile95th=\" 0.94999999999999996\" />\r \n </UncertainOrdinate>\r \n </Ordinates>\r \n </IntervalDistributions>" ;
104+ for ( int i = 0 ; i < 10 ; i ++ )
105+ {
106+ var distEl = XElement . Parse ( testEl ) ;
107+ UncertainOrderedPairedData newSet1 = new UncertainOrderedPairedData ( distEl ) ;
108+ }
109+ }
110+
98111 /// <summary>
99112 /// Test the CurveSample() method
100113 /// </summary>
@@ -105,7 +118,7 @@ public void Test_CurveSample()
105118 OrderedPairedData data2 = _dataset2 . CurveSample ( ) ;
106119 OrderedPairedData data3 = _dataset3 . CurveSample ( ) ;
107120 OrderedPairedData data4 = _dataset4 . CurveSample ( ) ;
108-
121+
109122 double [ ] xVals = new double [ ] { 1 , 2 , 3 , 5 } ;
110123 // mean = (min + max + mode) / 3
111124 double [ ] yMeanVals = new double [ ] { 2 , 3.66667 , 8.66667 , 17.33333 } ;
@@ -226,17 +239,17 @@ public void Test_IList()
226239 // Test InsertRange
227240 var toInsert = new List < UncertainOrdinate > ( ) { new UncertainOrdinate ( 1 , new Triangular ( 1 , 2 , 3 ) ) , new UncertainOrdinate ( 2 , new Triangular ( 2 , 4 , 5 ) ) } ;
228241 pairedData . InsertRange ( 0 , toInsert ) ;
229- for ( int j = 0 ; j < toInsert . Count ; j ++ )
242+ for ( int j = 0 ; j < toInsert . Count ; j ++ )
230243 {
231244 Assert . IsTrue ( pairedData . Contains ( toInsert [ j ] ) ) ;
232245 }
233246
234247 // Test AddRange
235- var toAdd = new List < UncertainOrdinate > ( ) { new UncertainOrdinate ( 3 , new Triangular ( 6 , 8 , 12 ) ) , new UncertainOrdinate ( 5 , new Triangular ( 13 , 19 , 20 ) ) , new UncertainOrdinate ( 7 , new Triangular ( 16 , 22 , 28 ) ) } ;
248+ var toAdd = new List < UncertainOrdinate > ( ) { new UncertainOrdinate ( 3 , new Triangular ( 6 , 8 , 12 ) ) , new UncertainOrdinate ( 5 , new Triangular ( 13 , 19 , 20 ) ) , new UncertainOrdinate ( 7 , new Triangular ( 16 , 22 , 28 ) ) } ;
236249 pairedData . AddRange ( toAdd ) ;
237250 var test7 = pairedData . Count ( ) ;
238251 Assert . AreEqual ( 7 , test7 ) ;
239- for ( int k = 0 ; k < toAdd . Count ( ) ; k ++ )
252+ for ( int k = 0 ; k < toAdd . Count ( ) ; k ++ )
240253 {
241254 Assert . IsTrue ( pairedData . Contains ( toAdd [ k ] ) ) ;
242255 }
0 commit comments