Esempio n. 1
0
        public void InegrationTest()
        {
            Logger.LogLevel = LogLevel.Silent;

            var model    = Model.Load("../../../src/tapi.unittest/sharp_ppm_tests/config_sharp.xml");
            var loadData = new LoadData
            {
                Model     = model,
                Dir       = "../../../src/tapi.unittest/sharp_ppm_tests",
                StartDate = model.From,
                EndDate   = model.To
            };

            loadData.ExecuteAsync().Wait();

            using (var package = new ExcelPackage(new FileInfo("../../../src/tapi.unittest/sharp_ppm_tests/Kontrollkörningar TAPI 3 - till Joakim 20170428_2.xlsx")))
            {
                foreach (var r in model.Reports)
                {
                    var report = new CalculateReport();
                    var(accutal, file) = report.Execute(r, loadData.Events, "");

                    var sheet = package.Workbook.Worksheets.Where(x => x.Name == r.Name).FirstOrDefault();
                    Assert.True(sheet != null, $"Can't fin a sheet for {r.Name}");
                    var expected = SheetToDictionary(sheet);

                    foreach (var row in expected.OrderBy(x => x.Key))
                    {
                        foreach (var col in row.Value.OrderBy(x => x.Key))
                        {
                            var e = col.Value;

                            Assert.True(accutal.ContainsKey(row.Key), "The Result does not contain the row " + row.Key);
                            Assert.True(accutal[row.Key].ContainsKey(col.Key), $"{r.Name} does not contain the col {col.Key} for row {row.Key}");

                            var a = accutal[row.Key][col.Key];

                            Assert.True(Math.Abs(a - e) < 1, $"Error in cell {r.Name}=>{row.Key}=>{col.Key}, Expected: {e}, Actual: {a} ");
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        //  [Fact]
        public void InegrationTest()
        {
            Logger.LogLevel = LogLevel.Silent;

            var model    = Model.Load("../../../src/tapi.unittest/reports/config.xml");
            var loadData = new LoadData
            {
                Model     = model,
                Dir       = "../../../sample/data",
                StartDate = model.From,
                EndDate   = model.To
            };

            loadData.ExecuteAsync().Wait();

            foreach (var r in model.Reports)
            {
                var report  = new CalculateReport();
                var accutal = report.Execute(r, loadData.Events, "");

                switch (r.Name)
                {
                case "minutes_in_column":
                    var nbrOfColmns = Encoding.UTF8.GetString(accutal.file)
                                      .Split(new string[] { Environment.NewLine }, StringSplitOptions.None)
                                      .First()
                                      .Split('\t')
                                      .Count();
                    Assert.Equal(24 * 60 + 1, nbrOfColmns);
                    break;

                default:
                    var expected = File.ReadAllBytes(Path.Combine("../../../src/tapi.unittest/reports/", r.FileName));
                    Assert.Equal(expected, accutal.file);
                    break;
                }
            }
        }
Esempio n. 3
0
 private async void NewsFactory_TimeToUpdate(object sender, EventArgs e) => await LoadData.ExecuteAsync();