public void CalculateSumOfAllValuesShouldCalculateValues()
        {
            DataFile file1 = CreateDataFile("myName_Waiting", StatusHelper.Waiting);
            DataFile file2 = CreateDataFile("myName_Processing", StatusHelper.Processing);
            DataFile file3 = CreateDataFile("myName_Cancelled", StatusHelper.Cancelled);

            file1.AddLine("1229212214291", "10", "Pays-Bas");
            file1.AddLine("1229212214291", "20", "Pays-Bas");
            file2.AddLine("1229212211641", "12", "Italie");
            file2.AddLine("1229212211641", "5", "Italie");
            Repositories.Files.Add(file1);
            Repositories.Files.Add(file2);
            Repositories.Files.Add(file3);
            Repositories.SaveChanges();

            List <SumValueStringBean> result = Repositories.Files.CalculateSumOfAllValues();

            Assert.AreEqual(2, result.Count());
            SumValueStringBean element = result.ElementAt(0);

            Assert.AreEqual("myName_Waiting", element.Source);
            Assert.AreEqual(30, element.Value);
            element = result.ElementAt(1);
            Assert.AreEqual("myName_Processing", element.Source);
            Assert.AreEqual(17, element.Value);
        }
Ejemplo n.º 2
0
 private void InsertLine(string line, DataFile dataFile, EntitiesContext context)
 {
     string[] splitted = line.Split(Convert.ToChar(","));
     if (splitted != null && splitted.Count() == 3)
     {
         DataLine dataLine = dataFile.AddLine(splitted[0], splitted[1], splitted[2]);
         context.Lines.Add(dataLine);
     }
 }
Ejemplo n.º 3
0
        public void CalculateSumByOriginShouldCalculateValues()
        {
            DataFile file1 = CreateDataFile("myName_Waiting", StatusHelper.Waiting);
            DataFile file2 = CreateDataFile("myName_Processing", StatusHelper.Processing);
            DataFile file3 = CreateDataFile("myName_Cancelled", StatusHelper.Cancelled);

            file1.AddLine("1229212214291", "10", "Pays-Bas");
            file1.AddLine("1229212214291", "5", "Pays-Bas");
            file2.AddLine("1229212211641", "22", "Italie");
            file2.AddLine("1229212211641", "3", "Italie");
            var timestamp = ConvertToTimestamp(new DateTime(2012, 10, 10)).ToString();

            file2.AddLine(timestamp, "3", "Italie");
            Repositories.Files.Add(file1);
            Repositories.Files.Add(file2);
            Repositories.Files.Add(file3);
            Repositories.SaveChanges();

            List <SumValueOriginBean> result = Repositories.FileLines.CalculateSumByOrigin();

            Assert.AreEqual(3, result.Count());
            var element = result.ElementAt(0);

            Assert.AreEqual("Italie", element.Source);
            var elementDateValue = element.Dates;

            Assert.AreEqual(GetDateToShort("1229212214291"), elementDateValue.GetDate());
            Assert.AreEqual(25, elementDateValue.Value);

            element = result.ElementAt(1);
            Assert.AreEqual("Italie", element.Source);
            elementDateValue = element.Dates;
            Assert.AreEqual(GetDateToShort(timestamp), elementDateValue.GetDate());
            Assert.AreEqual(3, elementDateValue.Value);

            element = result.ElementAt(2);
            Assert.AreEqual("Pays-Bas", element.Source);
            elementDateValue = element.Dates;
            Assert.AreEqual(GetDateToShort("1229212214291"), elementDateValue.GetDate());
            Assert.AreEqual(15, elementDateValue.Value);
        }
Ejemplo n.º 4
0
        public void CalculateSumByDateShouldCalculateValues()
        {
            DataFile file1 = CreateDataFile("myName_Waiting", StatusHelper.Waiting);
            DataFile file2 = CreateDataFile("myName_Processing", StatusHelper.Processing);
            DataFile file3 = CreateDataFile("myName_Cancelled", StatusHelper.Cancelled);

            file1.AddLine("1229212214291", "10", "Pays-Bas");
            file1.AddLine("1229212214291", "5", "Pays-Bas");
            file2.AddLine("1229212211641", "22", "Italie");
            file2.AddLine("1229212211641", "3", "Italie");
            Repositories.Files.Add(file1);
            Repositories.Files.Add(file2);
            Repositories.Files.Add(file3);
            Repositories.SaveChanges();

            List <SumValueDateBean> result = Repositories.FileLines.CalculateSumByDate();

            Assert.AreEqual(1, result.Count());
            SumValueDateBean element = result.FirstOrDefault();

            Assert.AreEqual(GetDateToShort("1229212214291"), element.GetDate());
            Assert.AreEqual(40, element.Value);
        }