Skip to content

Commit

Permalink
Build on Linux with VSCode, Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingy committed Aug 24, 2019
1 parent d8e2d2f commit 56a734c
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 391 deletions.
30 changes: 30 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,30 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run NUnit Tests",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "/usr/bin/dotnet",
"args": ["test"],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "Launch Sample Application",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Sample/bin/Debug/netcoreapp2.0/Sample.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
},
]
}
31 changes: 31 additions & 0 deletions .vscode/tasks.json
@@ -0,0 +1,31 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet build",
"type": "shell",
"args": [
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"label": "copytestdocs",
"command": "cp SimpleBrowser.UnitTests/SampleDocs SimpleBrowser.UnitTests/bin/Debug/",
"type": "shell",
"args": [
],
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
48 changes: 0 additions & 48 deletions Sample/Sample.Mono.csproj

This file was deleted.

64 changes: 0 additions & 64 deletions SimpleBrowser.Mono.sln

This file was deleted.

3 changes: 2 additions & 1 deletion SimpleBrowser.UnitTests/OfflineTests/CommentElements.cs
Expand Up @@ -7,6 +7,7 @@

namespace SimpleBrowser.UnitTests.OfflineTests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void HtmlElement_Comment()
Assert.That(comment.ToString(), Is.EqualTo("<!--[endif]-->"));

comment = comments.Skip(5).First();
Assert.That(comment.ToString(), Is.EqualTo("<!--[if gt IE 10]>\r\n<a id=\"link2\" href=\"http://www.microsoft.com\">Downlevel-hidden conditional comment test</a>\r\n<![endif]-->"));
Assert.That(comment.ToString(), Is.EqualTo("<!--[if gt IE 10]>" + Environment.NewLine + "<a id=\"link2\" href=\"http://www.microsoft.com\">Downlevel-hidden conditional comment test</a>" + Environment.NewLine + "<![endif]-->"));
}

/// <summary>
Expand Down
38 changes: 34 additions & 4 deletions SimpleBrowser.UnitTests/OfflineTests/FileUri.cs
Expand Up @@ -18,9 +18,23 @@ public class FileUri
[Test]
public void CanLoadHtmlFromFile()
{
FileInfo f = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SampleDocs\movies1.htm"));
string uri = string.Format("file:///{0}", f.FullName);
uri = uri.Replace("\\", "/");
FileInfo f = null;
string uri = string.Empty;
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
f = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SampleDocs\movies1.htm"));
uri = string.Format("file:///{0}", f.FullName);
uri = uri.Replace("\\", "/");
}
else if (Environment.OSVersion.Platform == PlatformID.Unix)
{
f = new FileInfo(Path.Combine("home", AppDomain.CurrentDomain.BaseDirectory, @"SampleDocs/movies1.htm"));
uri = string.Format("file://{0}", f.FullName);
}
else
{
throw new NotImplementedException("Please write unit tests for this unknown platform. (MacOS?)");
}

Browser b = new Browser();
b.Navigate(uri);
Expand All @@ -30,7 +44,8 @@ public void CanLoadHtmlFromFile()
[Test]
public void CanLoadHtmlFromFilesWithAbsolutePath()
{
if (Directory.Exists("C:\\Windows\\Temp"))
if (Environment.OSVersion.Platform == PlatformID.Win32NT &&
Directory.Exists("C:\\Windows\\Temp"))
{
File.Copy(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"SampleDocs\movies1.htm"),
Expand All @@ -48,6 +63,21 @@ public void CanLoadHtmlFromFilesWithAbsolutePath()

b.Navigate("file://\\c|\\Windows\\Temp\\movies1.htm");
Assert.AreEqual(b.Select("ul#menu>li").Count(), 3);

File.Delete(@"C:\Windows\Temp\movies1.htm");
}
else if (Environment.OSVersion.Platform == PlatformID.Unix &&
Directory.Exists("/tmp"))
{
File.Copy(
Path.Combine("home", AppDomain.CurrentDomain.BaseDirectory, @"SampleDocs/movies1.htm"),
@"/tmp/movies1.htm", true);

Browser b = new Browser();
b.Navigate("file:///tmp/movies1.htm");
Assert.AreEqual(b.Select("ul#menu>li").Count(), 3);

File.Delete(@"/tmp/movies1.htm");
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions SimpleBrowser.UnitTests/OnlineTests/RefererHeader.cs
Expand Up @@ -21,7 +21,7 @@ public class RefererHeader
[Test]
public void When_Testing_Referer_NoneWhenDowngrade_Typical()
{
string startingUrl = "http://afn.org/~afn07998/simplebrowser/test1.htm";
string startingUrl = "http://yenc-post.org/simplebrowser/test1.htm";

Browser b = new Browser();
Assert.AreEqual(b.RefererMode, Browser.RefererModes.NoneWhenDowngrade);
Expand All @@ -45,7 +45,7 @@ public void When_Testing_Referer_NoneWhenDowngrade_Typical()
[Test]
public void When_Testing_Referer_None_Typical()
{
string startingUrl = "http://afn.org/~afn07998/simplebrowser/test1.htm";
string startingUrl = "http://yenc-post.org/simplebrowser/test1.htm";

Browser b = new Browser();
b.RefererMode = Browser.RefererModes.None;
Expand Down Expand Up @@ -137,9 +137,9 @@ public void When_Testing_Referer_Unsafe_Url_Secure_Transition()
HtmlResult link = b.Find("ctl00_AdvertiseLink");
Assert.IsNotNull(link);

link.XElement.SetAttributeValue("href", "http://afn.org/~afn07998/simplebrowser/testmeta.htm");
link.XElement.SetAttributeValue("href", "http://yenc-post.org/simplebrowser/testmeta.htm");
string targetHref = link.GetAttribute("href");
Assert.AreEqual(targetHref, "http://afn.org/~afn07998/simplebrowser/testmeta.htm");
Assert.AreEqual(targetHref, "http://yenc-post.org/simplebrowser/testmeta.htm");

link.Click();
Assert.IsNotNull(b.CurrentState);
Expand All @@ -153,7 +153,7 @@ public void When_Testing_Referer_Unsafe_Url_Secure_Transition()
[Test]
public void When_Testing_Referer_MetaReferrer()
{
string startingUrl = "http://afn.org/~afn07998/simplebrowser/testmeta.htm";
string startingUrl = "http://yenc-post.org/simplebrowser/testmeta.htm";

Browser b = new Browser();
Assert.AreEqual(b.RefererMode, Browser.RefererModes.NoneWhenDowngrade);
Expand All @@ -177,7 +177,7 @@ public void When_Testing_Referer_MetaReferrer()
[Test]
public void When_Testing_Referer_RelNoReferrer()
{
string startingUrl = "http://afn.org/~afn07998/simplebrowser/testrel.htm";
string startingUrl = "http://yenc-post.org/simplebrowser/testrel.htm";

Browser b = new Browser();
Assert.AreEqual(b.RefererMode, Browser.RefererModes.NoneWhenDowngrade);
Expand Down

0 comments on commit 56a734c

Please sign in to comment.