2025-06-05 14:03:55 +02:00
|
|
|
|
using BeWo.Data.Access;
|
|
|
|
|
|
using BeWo.Data.Models.XRechnung;
|
|
|
|
|
|
using BeWo.Service.ServiceProxy;
|
|
|
|
|
|
using BeWo.Service.ServiceUtils;
|
2024-12-10 13:59:43 +01:00
|
|
|
|
using BS.Shared.AppSender;
|
2024-12-20 10:05:42 +01:00
|
|
|
|
using BS.Shared.DataContracts.Invoicing.XRechnung;
|
2024-12-10 13:59:43 +01:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.IO;
|
2025-06-05 14:03:55 +02:00
|
|
|
|
using System.Security.Policy;
|
2024-12-16 12:41:11 +01:00
|
|
|
|
using System.Text.RegularExpressions;
|
2025-06-05 14:03:55 +02:00
|
|
|
|
using static System.Net.WebRequestMethods;
|
2024-12-10 13:59:43 +01:00
|
|
|
|
|
|
|
|
|
|
namespace XRechnungUnitTest
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestClass]
|
|
|
|
|
|
public class UnitTest1
|
|
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
public string Url { get; set; }
|
|
|
|
|
|
public string ValidDownloadUrl { get; set; }
|
|
|
|
|
|
public string InvalidDownloadUrl { get; set; }
|
|
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
public string InvoiceTest { get; set; }
|
|
|
|
|
|
public XRechnung XRechnung { get; set; }
|
2025-06-05 14:03:55 +02:00
|
|
|
|
public XRechnungApiClient ValidApiClient { get; set; }
|
|
|
|
|
|
public XRechnungApiClient InvalidApiClient { get; set; }
|
2024-12-10 13:59:43 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
[TestInitialize]
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
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();
|
2025-01-17 11:08:46 +01:00
|
|
|
|
XRechnung = JsonConvert.DeserializeObject<XRechnung>(InvoiceTest);
|
2024-12-10 13:59:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-12-20 10:05:42 +01:00
|
|
|
|
[TestMethod]
|
2025-06-05 14:03:55 +02:00
|
|
|
|
public void SendRequestInvoiceTestString()
|
2024-12-20 10:05:42 +01:00
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
var response = ValidApiClient.Create(InvoiceTest);
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
Assert.IsFalse(response.HasErrors);
|
|
|
|
|
|
}
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
[TestMethod]
|
2025-06-05 14:03:55 +02:00
|
|
|
|
public void SendRequestXRechnungObject()
|
2025-01-17 11:08:46 +01:00
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
var response = ValidApiClient.Create(XRechnung);
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
Assert.IsFalse(response.HasErrors);
|
2024-12-20 10:05:42 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
2025-06-05 14:03:55 +02:00
|
|
|
|
public void SendRequestInvoiceTestStringValidUrl()
|
2024-12-20 10:05:42 +01:00
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
var response = ValidApiClient.Create(InvoiceTest, ValidDownloadUrl);
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-06-05 14:03:55 +02:00
|
|
|
|
Assert.IsFalse(response.HasErrors);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void SendRequestValidUrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
var response = ValidApiClient.Create(XRechnung, ValidDownloadUrl);
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
Assert.IsFalse(response.HasErrors);
|
|
|
|
|
|
}
|
2024-12-20 10:05:42 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
[TestMethod]
|
|
|
|
|
|
public void SendRequestInvalidUrl()
|
|
|
|
|
|
{
|
2025-06-05 14:03:55 +02:00
|
|
|
|
var response = InvalidApiClient.Create(XRechnung, InvalidDownloadUrl);
|
2024-12-11 12:08:16 +01:00
|
|
|
|
|
2025-01-17 11:08:46 +01:00
|
|
|
|
Assert.IsTrue(response.HasErrors);
|
2024-12-10 13:59:43 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|