Skip to content

Commit f2d933b

Browse files
committed
[Branches/1.0] added test covering workitem #27115, this class also shows a starting point to create new tests for WmsLayer.
git-tfs-id: [https://tfs.codeplex.com/tfs/TFS01]$/SharpMap/Branches/1.0;C105514
1 parent e23df66 commit f2d933b

3 files changed

Lines changed: 818 additions & 0 deletions

File tree

UnitTests/Layers/WmsLayerTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Drawing;
3+
using System.Web;
4+
using GeoAPI.Geometries;
5+
using NUnit.Framework;
6+
using SharpMap.Layers;
7+
using SharpMap.Web.Wms;
8+
9+
namespace UnitTests.Layers
10+
{
11+
[TestFixture]
12+
public class WmsLayerTest
13+
{
14+
[Test(Description = "BgColor produces a correct url when used with a named color")]
15+
public void BgColor_NamedColor_SetUrlPropertyCorrectly()
16+
{
17+
var client = CreateClientFromXmlResult("wms.atlantedesertificazione.xml");
18+
19+
var layer = new WmsLayer("wms", client) {BgColor = Color.Red, SRID = 0, Transparent = false};
20+
21+
var url = layer.GetRequestUrl(new Envelope(1, 1, 1, 1), new Size(1, 1));
22+
var queryString = HttpUtility.ParseQueryString(url);
23+
24+
Assert.That(queryString["BGCOLOR"], Is.EqualTo("#FF0000"),
25+
"Layer.BgColor does not produce a valid Url");
26+
}
27+
28+
private Client CreateClientFromXmlResult(string xmlFilename)
29+
{
30+
var resourceName = typeof (WmsLayerTest).Namespace + "." + xmlFilename;
31+
var resourceStream = typeof(WmsLayerTest).Assembly.GetManifestResourceStream(resourceName);
32+
Assert.That(resourceStream, Is.Not.Null, "Wrong test: Invalid resource name");
33+
34+
var buffer = new byte[resourceStream.Length];
35+
resourceStream.Read(buffer, 0, Convert.ToInt32(resourceStream.Length));
36+
37+
var client = new Client(buffer);
38+
return client;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)