Esempio n. 1
0
        public void LoadSaveInvoiceTest(FileNameTestCase testCase)
        {
            Console.WriteLine($"{testCase.Version}->{testCase.InputFile}");
            var ebiList = InvoiceFactory.GetVersionsWithSaveSupported();
            var dlgMoq  = new Mock <IDialogService>();

            dlgMoq.Setup(dlg => dlg.ShowMessageBox(It.IsAny <string>(),
                                                   It.IsAny <string>(),
                                                   It.Is <MessageBoxButtons>(mb => mb == MessageBoxButtons.YesNo),
                                                   It.IsAny <MessageBoxIcon>())).Returns(DialogResult.OK);

            string iFn   = testCase.InputFile;
            string oFn   = testCase.OutputFile;
            var    invVM = Cmn.UContainer.Resolve <InvoiceViewModel>(new ResolverOverride[] {
                new ParameterOverride("invoice", Cmn.Invoice),
                new ParameterOverride("dialog", dlgMoq.Object)
            });

            invVM.LoadTemplateCommand.Execute(iFn);
            PlugInSettings.Default.EbInterfaceVersionString = testCase.Version;
            string oFnTagged = Path.GetFileNameWithoutExtension(oFn);

            invVM.SaveEbinterfaceCommand.Execute(oFn);
            if (!invVM.Results.IsValid)
            {
                foreach (var item in invVM.Results)
                {
                    Console.WriteLine(item.Message);
                }
            }
            Assert.IsTrue(File.Exists(oFn), "Outputfile missing - " + testCase.Version);
        }
Esempio n. 2
0
        public void NotVatBerechtigtTest(FileNameTestCase fileNameTestCase)
        {
            var dlgMoq = new Mock <IDialogService>();

            dlgMoq.Setup(dlg => dlg.ShowMessageBox(It.IsAny <string>(),
                                                   It.IsAny <string>(),
                                                   It.Is <MessageBoxButtons>(mb => mb == MessageBoxButtons.YesNo),
                                                   It.IsAny <MessageBoxIcon>())).Returns(DialogResult.OK);

            string invoiceFn = fileNameTestCase.InputFile;  //@"Daten\testTemplateInvoiceIndustry.xml";
            string outFn     = fileNameTestCase.OutputFile; //@"Daten\testInvoiceNotVatBerechtigt.xml";

            PlugInSettings.Default.VStBerechtigt = false;
            PlugInSettings.Default.VStText       = "Ich bin nicht berechtigt";
            var invVM = Cmn.UContainer.Resolve <InvoiceViewModel>(new ResolverOverride[] {
                new ParameterOverride("invoice", Cmn.Invoice),
                new ParameterOverride("dialog", dlgMoq.Object)
            });

            invVM.LoadTemplateCommand.Execute(invoiceFn);
            //Assert.Multiple(() =>
            //{
            foreach (var item in invVM.DetailsView)
            {
                Assert.That(item.IsVatBerechtigt == false, "Vat berechtigt false");
                item.VatItem.PrintDump();
                Assert.AreEqual(item.VatItem, PlugInSettings.Default.MwStDefaultValue, "MwStDefaultValue");
            }
            //});
            Assert.IsTrue(invVM.IsInvoiceValid(), "Invoice IsValid() == false");
            PlugInSettings.Default.EbInterfaceVersionString = fileNameTestCase.Version; //EbIVersion.V4P3.ToString();
            invVM.SaveEbinterfaceCommand.Execute(outFn);
            if (!invVM.Results.IsValid)
            {
                foreach (var item in invVM.Results)
                {
                    Console.WriteLine(item.Message);
                }
            }
            Assert.IsTrue(invVM.Results.IsValid, "Invoice not valid");
            Assert.IsTrue(File.Exists(outFn), "Output file not found");
        }