-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathXMLReciverConditionalTest.cs
More file actions
68 lines (55 loc) · 2.86 KB
/
XMLReciverConditionalTest.cs
File metadata and controls
68 lines (55 loc) · 2.86 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FakeServers;
using FakeServers.Http;
using FakeServers.ReceiverConditionals;
namespace FakeHttpServerTests.ReciverConditionalsTests
{
/// <summary>
/// Сводное описание для XMLReciverConditionalTests
/// </summary>
[TestClass]
public class XMLReciverConditionalTest
{
private IFakeServer fakeserver;
private const string SUCCESS_RESPONSE = "Ok";
private const string LISTNED_HOST = "http://localhost:3030/";
[TestCleanup]
public void ShoutDownServer()
{
fakeserver.StopServer();
}
[TestMethod]
public void FakeServer_should_able_to_compare_XML_body_with_different_representation()
{
const string EXPECTED_XML = "<?xml version=\"1.0\" encoding=\"utf - 8\"?><some-tag>value of some tag</some-tag>";
const string ACTUAL_XML = "<?xml version=\"1.0\" encoding=\"utf - 8\"?>\n" +
" <!-- some comment -->\n" +
" <some-tag>value of some tag</some-tag>";
fakeserver = new FakeHttpServer(LISTNED_HOST);
fakeserver.ShouldReceived(new XMLReceiverConditional()).Post(EXPECTED_XML).Response(SUCCESS_RESPONSE);
string actualResponse = HttpSender.SendPost(LISTNED_HOST, ACTUAL_XML);
Assert.AreEqual(SUCCESS_RESPONSE, actualResponse, "Wrong response");
fakeserver.CheckAllReceiverConditional();
}
[TestMethod]
public void FakeServer_should_able_to_compare_XML_body_with_ignore_some_node()
{
const string EXPECTED_XML = "<?xml version=\"1.0\" encoding=\"utf - 8\"?>\n" +
" <root>\n" +
" <some-tag>value of some tag</some-tag>\n" +
" <ignored-node>#:={Ignore the node}</ignored-node>" +
" </root>";
const string ACTUAL_XML = "<?xml version=\"1.0\" encoding=\"utf - 8\"?>\n" +
" <root>\n"+
" <ignored-node>some value</ignored-node>\n"+
" <some-tag>value of some tag</some-tag>\n"+
" </root>";
fakeserver = new FakeHttpServer(LISTNED_HOST);
//For this fiture should use XMLWithIgnoreNodeRreceiverConditional
fakeserver.ShouldReceived(new XMLWithIgnoreNodeReceiverConditional()).Post(EXPECTED_XML).Response(SUCCESS_RESPONSE);
string actualResponse = HttpSender.SendPost(LISTNED_HOST, ACTUAL_XML);
Assert.AreEqual(SUCCESS_RESPONSE, actualResponse, "Wrong response");
fakeserver.CheckAllReceiverConditional();
}
}
}