-
Notifications
You must be signed in to change notification settings - Fork 22
/
XmlExporterTest.cs
56 lines (52 loc) · 1.73 KB
/
XmlExporterTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
using VerifyTests;
using VerifyXunit;
using Xunit;
namespace ProductExport
{
[UsesVerify]
public class XmlExporterTest
{
[Fact]
public Task ExportFull()
{
var orders = new List<Order>() {SampleModelObjects.RecentOrder, SampleModelObjects.OldOrder};
var xml = XmlExporter.ExportFull(orders);
return Verifier.VerifyXml(xml);
}
[Fact]
public Task ExportTaxDetails()
{
var orders = new List<Order>() {SampleModelObjects.RecentOrder, SampleModelObjects.OldOrder};
var xml = XmlExporter.ExportTaxDetails(orders);
return Verifier.VerifyXml(xml);
}
[Fact]
public Task ExportStore()
{
var store = SampleModelObjects.FlagshipStore;
var xml = XmlExporter.ExportStore(store);
return Verifier.VerifyXml(xml);
}
[Fact]
public Task ExportHistory()
{
var orders = new List<Order>() {SampleModelObjects.RecentOrder, SampleModelObjects.OldOrder};
var xml = XmlExporter.ExportHistory(orders);
var settings = new VerifySettings();
settings.AddScrubber(
input =>
{
var regex = "createdAt=\"[^\"]+\"";
var replacement = "createdAt=\"2018-09-20T00:00Z\"";
var scrubbed = Regex.Replace(input.ToString(), regex, replacement);
input.Clear().Append(scrubbed);
});
return Verifier.VerifyXml(xml, settings);
}
}
}