Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
info authored and info committed Jan 30, 2017
1 parent c741067 commit 4dd5b97
Show file tree
Hide file tree
Showing 10 changed files with 594 additions and 0 deletions.
36 changes: 36 additions & 0 deletions WebLinksNet.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WebLinksNet.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebLinksNet.Tests")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9d2104c5-1897-4f3d-90ec-0491ed303d1f")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
89 changes: 89 additions & 0 deletions WebLinksNet.Tests/WebLinksNet.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{9D2104C5-1897-4F3D-90EC-0491ED303D1F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebLinksNet.Tests</RootNamespace>
<AssemblyName>WebLinksNet.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
</ItemGroup>
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="WebLinksParserTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WebLinksNet\WebLinksNet.csproj">
<Project>{395e7bc1-1042-4094-8426-3935ce0fe36a}</Project>
<Name>WebLinksNet</Name>
</ProjectReference>
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
76 changes: 76 additions & 0 deletions WebLinksNet.Tests/WebLinksParserTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WebLinksNet;

namespace WebLinksNet.Tests
{
[TestClass]
public class WebLinksParserTests
{
/// <summary>
/// Test the execution of the parser with an empty parameter. An empty list should be returned.
/// </summary>
[TestMethod]
public void TestEmpty()
{
var result = WebLinksParser.Parse("");
Assert.IsNotNull(result);
Assert.IsTrue(result.Count == 0);
}

/// <summary>
/// Test the execution of the parser with a null parameter. An exception should be thrown.
/// </summary>
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void TestNull()
{
WebLinksParser.Parse(null);
}

/// <summary>
/// Parse a simple WebLink
/// </summary>
[TestMethod]
public void TestSimpleParse()
{
var result = WebLinksParser.Parse("</entries?page=2>; rel=\"next\" title=\"This is a test\"");

Assert.IsNotNull(result);
Assert.IsTrue(result.Count == 1);

var webLink = result[0];
Assert.AreEqual("/entries?page=2", webLink.Url, "Url property");
Assert.AreEqual("next", webLink.Rel, "Rel property");
Assert.AreEqual("This is a test", webLink.Title, "Title proprty");
}

/// <summary>
/// Parse Test parsing multiple WebLinks
/// </summary>
[TestMethod]
public void TestMultipleParse()
{
var result = WebLinksParser.Parse("</entries?page=2>; rel=\"next\", </entries?page=9>; rel=\"last\"");

Assert.IsNotNull(result);
Assert.IsTrue(result.Count == 2);
}

/// <summary>
/// Tests if a WebLink .ToString() works as expected
/// </summary>
[TestMethod]
public void TestWebLinkToString()
{
var webLink = new WebLink()
{
Url = "/entries?page=2",
Title = "Simple Title",
Rel = "next"
};

Assert.AreEqual("", webLink.ToString());
}
}
}
58 changes: 58 additions & 0 deletions WebLinksNet.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebLinksNet", "WebLinksNet\WebLinksNet.csproj", "{395E7BC1-1042-4094-8426-3935CE0FE36A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebLinksNet.Tests", "WebLinksNet.Tests\WebLinksNet.Tests.csproj", "{9D2104C5-1897-4F3D-90EC-0491ED303D1F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|ARM.ActiveCfg = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|ARM.Build.0 = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|x64.ActiveCfg = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|x64.Build.0 = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|x86.ActiveCfg = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Debug|x86.Build.0 = Debug|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|Any CPU.Build.0 = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|ARM.ActiveCfg = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|ARM.Build.0 = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|x64.ActiveCfg = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|x64.Build.0 = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|x86.ActiveCfg = Release|Any CPU
{395E7BC1-1042-4094-8426-3935CE0FE36A}.Release|x86.Build.0 = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|ARM.Build.0 = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|x64.ActiveCfg = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|x64.Build.0 = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|x86.ActiveCfg = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Debug|x86.Build.0 = Debug|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|Any CPU.Build.0 = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|ARM.ActiveCfg = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|ARM.Build.0 = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|x64.ActiveCfg = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|x64.Build.0 = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|x86.ActiveCfg = Release|Any CPU
{9D2104C5-1897-4F3D-90EC-0491ED303D1F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
36 changes: 36 additions & 0 deletions WebLinksNet/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WebLinksNet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WebLinksNet")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("395e7bc1-1042-4094-8426-3935ce0fe36a")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
90 changes: 90 additions & 0 deletions WebLinksNet/WebLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebLinksNet
{
/// <summary>
/// A WebLink object representing the web link data
/// </summary>
public class WebLink
{
/// <summary>
/// The list of attributes of the WebLink
/// </summary>
private readonly Dictionary<string, string> _attributes = new Dictionary<string, string>();

/// <summary>
/// The URL of the link
/// </summary>
public string Url { get; set; } = null;

/// <summary>
/// The title of the link
/// </summary>
public string Title
{
get
{
return this._attributes.ContainsKey("title") ? this._attributes["title"] : null;
}
set
{
this._attributes["title"] = value;
}
}

/// <summary>
/// The rel attribute of the link
/// </summary>
public string Rel
{
get
{
return this._attributes.ContainsKey("rel") ? this._attributes["rel"] : null;
}
set
{
this._attributes["rel"] = value;
}
}

/// <summary>
/// Returns a textual representation of the WebLink
/// </summary>
/// <returns></returns>
public override string ToString()
{
var sb = new StringBuilder();

sb.Append('<');
sb.Append(this.Url);
sb.Append(">; ");

foreach (var attr in this._attributes)
{
sb.Append('<');
}

return "";
}

/// <summary>
/// Register an attribute to the WebLink object
/// </summary>
/// <param name="attributeName"></param>
/// <param name="attributeValue"></param>
internal void AddAttribute(string attributeName, string attributeValue)
{
// Validate parameters
if (string.IsNullOrWhiteSpace(attributeName))
{
throw new ArgumentNullException(nameof(attributeName));
}

this._attributes.Add(attributeName, attributeValue);
}
}
}
Loading

0 comments on commit 4dd5b97

Please sign in to comment.