Beispiel #1
0
        public void Test1Month_2_Ovl_sameObisId()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month_2_ovl_sameObisId.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();
            var result = target.Calculate(deviceModel, supplierModel);

            Assert.AreEqual("2017-10-01T00:00:00+02:00", result.Data.Begin.ToString("yyyy-MM-ddTHH:mm:ssK"));
            Assert.AreEqual("2017-11-01T00:00:00+01:00", result.Data.End.ToString("yyyy-MM-ddTHH:mm:ssK"));

            var data = result.Data as Taf1Data;

            Assert.AreEqual(1, data.SummaryRegister.Count);
            Assert.AreEqual("1-0:1.8.1*255", data.SummaryRegister[0].ObisCode.ToString());
            Assert.AreEqual(57600, data.SummaryRegister[0].Amount);
            Assert.AreEqual(1, data.SummaryRegister[0].TariffId);

            Assert.AreEqual(2, data.AccountingSections.Count);
            Assert.AreEqual(29800, data.AccountingSections[0].MeasuringRanges[0].Amount);
            Assert.AreEqual(27800, data.AccountingSections[1].MeasuringRanges[0].Amount);
        }
Beispiel #2
0
        private static UsagePointLieferant LoadTafFile(string filename)
        {
            try
            {
                var xml = XDocument.Load(filename);

                Ar2418Validation.ValidateSchema(xml);
                var model = XmlModelParser.ParseSupplierModel(xml.Root?.Descendants());
                ModelValidation.ValidateSupplierModel(model);

                return(model);
            }
            catch (AggregateException ex)
            {
                foreach (var err in ex.InnerExceptions)
                {
                    Console.WriteLine(err.Message);
                }

                return(null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
        public void LoadSupplierXml()
        {
            this.LastErrorMessages.Clear();
            this.BreadCrumbTrail.RemoveUnselectedItems();

            try
            {
                Log.Information("Parsing supplier model");
                this.CurrentSupplierFile.Model = XmlModelParser.ParseSupplierModel(this.CurrentSupplierFile.Xml.Root.Descendants());

                Log.Information("Validating supplier model");
                ModelValidation.ValidateSupplierModel(this.CurrentSupplierFile.Model);
            }
            catch (AggregateException ex)
            {
                foreach (var err in ex.InnerExceptions)
                {
                    Log.Error(err, err.Message);
                    this.LastErrorMessages.Add(err.Message);
                }

                throw;
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Loading supplier file failed: {0}", ex.Message);
                this.LastErrorMessages.Add("Keine gültige Datei.");
                throw;
            }
        }
Beispiel #4
0
        public void TestTaf1ExceptionToMuchTariffStages()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month_2_DayProfiles.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual("Die Anzahl der Tarifstufen darf die Anzahl der originären Messwertlisten nicht überschreiten.", ex.Message);
        }
Beispiel #5
0
        public void TestTaf1ExceptionAMeterReadingIsNotAnOVL()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month_1_ovl_1_meterReading.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual("Es sind nur originäre Messwertlisten zulässig.", ex.Message);
        }
Beispiel #6
0
        public void TestTaf1ExceptionTooManyOVL()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month_4_ovl.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual("Es werden maximal 3 originäre Messwertlisten unterstützt.", ex.Message);
        }
Beispiel #7
0
        public void TestTaf1ExceptionEndValuePTBStatus4()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month_end_statusPTB4.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var end = supplierModel.AnalysisProfile.BillingPeriod.GetEnd();

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual($"Zu dem Zeitpunkt {end} ist kein Wert vorhanden oder der Status kritisch oder fatal.", ex.Message);
        }
Beispiel #8
0
        public void TestTaf1ExceptionInvalidBillingPeriodStart()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month_start_at_10_2.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var start = supplierModel.AnalysisProfile.BillingPeriod.Start;

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual($"Die Abrechnungsperiode {start} startet nicht am Monatsanfang.", ex.Message);
        }
Beispiel #9
0
        public void TestTaf1ExceptionInvalidSpecialDayProfilesCount()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_1_month_plus_1_day.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var start = supplierModel.AnalysisProfile.BillingPeriod.Start;
            var end   = supplierModel.AnalysisProfile.BillingPeriod.GetEnd();
            var days  = (int)(end - start).TotalDays;

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual($"Die Anzahl der SpecialDayProfile Objekte muss einem vielfachen von { days} entsprechen.", ex.Message);
        }
Beispiel #10
0
        public void TestTaf1ExceptionInvalidBillingPeriod2()
        {
            var deviceXml   = XDocument.Load(@"Data\result_1_month.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_InvalidBillingPeriod2.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();

            var start = supplierModel.AnalysisProfile.BillingPeriod.Start;
            var end   = supplierModel.AnalysisProfile.BillingPeriod.GetEnd();

            var ex = Assert.ThrowsException <InvalidOperationException>(() => target.Calculate(deviceModel, supplierModel));

            Assert.AreEqual($"Die angegebene Abrechnungsperiode von {(end - start).TotalDays} Tagen ist ungültigt. Unterstütz werden 1, 2, 3, 6 oder 12 Monate."
                            , ex.Message);
        }
Beispiel #11
0
        public void Test3Month()
        {
            var deviceXml   = XDocument.Load(@"Data\result_3_month.xml");
            var deviceModel = XmlModelParser.ParseHanAdapterModel(deviceXml.Root.Descendants());

            var supplierXml   = XDocument.Load(@"Data\supplier_3_month.xml");
            var supplierModel = XmlModelParser.ParseSupplierModel(supplierXml.Root.Descendants());

            var target = new TafAdapterTaf1();
            var result = target.Calculate(deviceModel, supplierModel);

            Assert.AreEqual("2017-08-01T00:00:00+02:00", result.Data.Begin.ToString("yyyy-MM-ddTHH:mm:ssK"));
            Assert.AreEqual("2017-11-01T00:00:00+01:00", result.Data.End.ToString("yyyy-MM-ddTHH:mm:ssK"));

            var data = result.Data as Taf1Data;

            Assert.AreEqual(1, data.SummaryRegister.Count);
            Assert.AreEqual("1-0:1.8.1*255", data.SummaryRegister[0].ObisCode.ToString());
            Assert.AreEqual(88360, data.SummaryRegister[0].Amount);
            Assert.AreEqual(1, data.SummaryRegister[0].TariffId);
        }