85 lines
2.1 KiB
C#
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.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);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendRequestValidUrl()
|
|
{
|
|
var response = ValidApiClient.Create(XRechnung, ValidDownloadUrl);
|
|
|
|
Assert.IsFalse(response.HasErrors);
|
|
}
|
|
|
|
[TestMethod]
|
|
public void SendRequestInvalidUrl()
|
|
{
|
|
var response = InvalidApiClient.Create(XRechnung, InvalidDownloadUrl);
|
|
|
|
Assert.IsTrue(response.HasErrors);
|
|
}
|
|
}
|
|
}
|