public void Test_MultiElements_Generate(double[] elements, bool offset)
        {
            double min    = elements.Min();
            double max    = elements.Max();
            double sum    = elements.Sum();
            int    counts = elements.Count();

            details.Add(new CdrTaRecord
            {
                TaMin = min,
                TaMax = max,
                TaSum = sum,
                TaInnerIntervalNum = counts,
                TaOuterIntervalNum = 0
            });
            FakeGenerateCdrTaRecordsService service = new FakeGenerateCdrTaRecordsService(details);
            List <CdrTaRecord> results = service.Generate();

            Assert.AreEqual(results.Count, 1);
            if (offset)
            {
                Assert.AreEqual(results[0].TaMax, max - min);
                Assert.AreEqual(results[0].TaMin, 0);
                Assert.AreEqual(results[0].TaAverage, sum / counts - min);
            }
            else
            {
                Assert.AreEqual(results[0].TaMax, max);
                Assert.AreEqual(results[0].TaMin, min);
                Assert.AreEqual(results[0].TaAverage, sum / counts);
            }
        }
 public void Test_MultiElements_Generate(double[] elements, bool offset)
 {
     double min = elements.Min();
     double max = elements.Max();
     double sum = elements.Sum();
     int counts = elements.Count();
     details.Add(new CdrTaRecord
     {
         TaMin = min,
         TaMax = max,
         TaSum = sum,
         TaInnerIntervalNum = counts,
         TaOuterIntervalNum = 0
     });
     FakeGenerateCdrTaRecordsService service = new FakeGenerateCdrTaRecordsService(details);
     List<CdrTaRecord> results = service.Generate();
     Assert.AreEqual(results.Count, 1);
     if (offset)
     {
         Assert.AreEqual(results[0].TaMax, max - min);
         Assert.AreEqual(results[0].TaMin, 0);
         Assert.AreEqual(results[0].TaAverage, sum/counts - min);
     }
     else
     {
         Assert.AreEqual(results[0].TaMax, max);
         Assert.AreEqual(results[0].TaMin, min);
         Assert.AreEqual(results[0].TaAverage, sum / counts);
     }
 }
        public void Test_TwoElements_Generate(double[] min, double[] max, bool[] result)
        {
            for (int i = 0; i < min.Length; i++)
            {
                details.Add(new CdrTaRecord
                {
                    TaMin = min[i],
                    TaMax = max[i],
                    TaSum = min[i] + max[i],
                    TaInnerIntervalNum = 1,
                    TaOuterIntervalNum = 1
                });
            }
            FakeGenerateCdrTaRecordsService service = new FakeGenerateCdrTaRecordsService(details);
            List <CdrTaRecord> results = service.Generate();

            Assert.AreEqual(results.Count, min.Length);
            for (int i = 0; i < min.Length; i++)
            {
                if (result[i])
                {
                    Assert.AreEqual(results[i].TaMax, max[i] - min[i]);
                    Assert.AreEqual(results[i].TaMin, 0);
                    Assert.AreEqual(results[i].TaAverage, (max[i] - min[i]) / 2);
                }
                else
                {
                    Assert.AreEqual(results[i].TaMax, max[i]);
                    Assert.AreEqual(results[i].TaMin, min[i]);
                    Assert.AreEqual(results[i].TaAverage, (max[i] + min[i]) / 2);
                }
            }
        }
 public void Test_TwoElements_Generate(double[] min, double[] max, bool[] result)
 {
     for (int i = 0; i < min.Length; i++)
     {
         details.Add(new CdrTaRecord
         {
             TaMin = min[i],
             TaMax = max[i],
             TaSum = min[i] + max[i],
             TaInnerIntervalNum = 1,
             TaOuterIntervalNum = 1
         });
     }
     FakeGenerateCdrTaRecordsService service = new FakeGenerateCdrTaRecordsService(details);
     List<CdrTaRecord> results = service.Generate();
     Assert.AreEqual(results.Count, min.Length);
     for (int i = 0; i < min.Length; i++)
     {
         if (result[i])
         {
             Assert.AreEqual(results[i].TaMax, max[i] - min[i]);
             Assert.AreEqual(results[i].TaMin, 0);
             Assert.AreEqual(results[i].TaAverage, (max[i] - min[i])/2);
         }
         else
         {
             Assert.AreEqual(results[i].TaMax, max[i]);
             Assert.AreEqual(results[i].TaMin, min[i]);
             Assert.AreEqual(results[i].TaAverage, (max[i] + min[i]) / 2);
         }
     }
 }