Files
BeWoPlaner/XRechnungUnitTest/UnitTest1.cs
Rene Evertz bcad1dd270 Merge branch 'master' into feature_rene_17_xrechnung
# Conflicts:
#	BeWo/BeWo.csproj
#	Service/Service.csproj
2025-06-11 13:29:31 +02:00

85 lines
2.1 KiB
C#

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()
{
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 SendRequestInvoiceTestString()
{
var response = ValidApiClient.Create(InvoiceTest);
Assert.IsTrue(response.Success);
}
[TestMethod]
public void SendRequestXRechnungObject()
{
var response = ValidApiClient.Create(XRechnung);
Assert.IsTrue(response.Success);
}
[TestMethod]
public void SendRequestInvoiceTestStringValidUrl()
{
var response = ValidApiClient.Create(InvoiceTest, ValidDownloadUrl);
Assert.IsTrue(response.Success);
}
[TestMethod]
public void SendRequestValidUrl()
{
var response = ValidApiClient.Create(XRechnung, ValidDownloadUrl);
Assert.IsTrue(response.Success);
}
[TestMethod]
public void SendRequestInvalidUrl()
{
var response = InvalidApiClient.Create(XRechnung, InvalidDownloadUrl);
Assert.IsFalse(response.Success);
}
}
}