LocalFileStorage

This commit is contained in:
2025-06-05 14:03:55 +02:00
parent 5e7080fd9d
commit ed4dc8fa75
24 changed files with 298 additions and 189 deletions

View File

@@ -1,32 +1,66 @@
using BeWo.Data.Models.XRechnung;
using BeWo.Service.ServiceUtils.XRechnung;
using BeWo.Data.Access;
using BeWo.Data.Models.XRechnung;
using BeWo.Service.ServiceProxy;
using BeWo.Service.ServiceUtils;
using BS.Shared.AppSender;
using BS.Shared.DataContracts.Invoicing.XRechnung;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
using System.IO;
using System.Security.Policy;
using System.Text.RegularExpressions;
using static System.Net.WebRequestMethods;
namespace XRechnungUnitTest
{
[TestClass]
public class UnitTest1
{
public string Url { get; set; }
public string ValidDownloadUrl { get; set; }
public string InvalidDownloadUrl { get; set; }
public string InvoiceTest { get; set; }
public XRechnung XRechnung { get; set; }
public XRechnungApiClient ValidApiClient { get; set; }
public XRechnungApiClient InvalidApiClient { get; set; }
[TestInitialize]
public void Init()
{
InvoiceTest = File.ReadAllText("invoicetest.json", System.Text.Encoding.UTF8);
Url = "https://test2.evplaner.de/xrg/";
ValidDownloadUrl = "https://app5.bewoplaner.de/service/ApiStreamService.svc/GetPdf";
InvalidDownloadUrl = "https://app5.bewoplaner.de/service/ApiStreamService.svc/GetFakePdf";
ValidApiClient = new XRechnungApiClient(Url);
InvalidApiClient = new XRechnungApiClient(Url);
InvoiceTest = ServiceConfigReader.GetInvoiceTestJsonString();
XRechnung = JsonConvert.DeserializeObject<XRechnung>(InvoiceTest);
}
[TestMethod]
public void SendRequest()
public void SendRequestInvoiceTestString()
{
var response = XRechnungSender.Send(XRechnung);
var response = ValidApiClient.Create(InvoiceTest);
Assert.IsFalse(response.HasErrors);
}
[TestMethod]
public void SendRequestXRechnungObject()
{
var response = ValidApiClient.Create(XRechnung);
Assert.IsFalse(response.HasErrors);
}
[TestMethod]
public void SendRequestInvoiceTestStringValidUrl()
{
var response = ValidApiClient.Create(InvoiceTest, ValidDownloadUrl);
Assert.IsFalse(response.HasErrors);
}
@@ -34,19 +68,7 @@ namespace XRechnungUnitTest
[TestMethod]
public void SendRequestValidUrl()
{
var url = "https://app5.bewoplaner.de/service/DownloadFile.aspx?key=jhkf4589141324h6543958";
var response = XRechnungSender.Send(XRechnung, url);
Assert.IsFalse(response.HasErrors);
}
[TestMethod]
public void SendRequestValidUrlEscape()
{
var url = Uri.EscapeDataString("https://app5.bewoplaner.de/service/DownloadFile.aspx?key=jhkf4589141324h6543958");
var response = XRechnungSender.Send(XRechnung, url);
var response = ValidApiClient.Create(XRechnung, ValidDownloadUrl);
Assert.IsFalse(response.HasErrors);
}
@@ -54,9 +76,7 @@ namespace XRechnungUnitTest
[TestMethod]
public void SendRequestInvalidUrl()
{
var url = "Hallo Mike!";
var response = XRechnungSender.Send(XRechnung, url);
var response = InvalidApiClient.Create(XRechnung, InvalidDownloadUrl);
Assert.IsTrue(response.HasErrors);
}