Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit d05577d

Browse files
committed
Init appveyor
Init codecov Init UnitTests
1 parent eb8b6c9 commit d05577d

19 files changed

+421
-75
lines changed

AfterTest.ps1

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
param (
2+
[string]$Version = "0.0.1"
3+
)
4+
$base_dir = split-path -parent $MyInvocation.MyCommand.Definition
5+
$output_dir = Join-Path $base_dir .\output
6+
$src_dir = Join-Path $base_dir .\RCONServerLib
7+
$nuspec = Get-ChildItem $src_dir\*.nuspec -Recurse
8+
9+
Write-Host "Nuspec: $nuspec"
10+
Remove-Item -force -Recurse $output_dir -ErrorAction SilentlyContinue > $null
11+
New-Item -ItemType directory -Path $output_dir > $null
12+
nuget pack $nuspec.FullName -Properties "Version=$Version" -OutputDirectory $output_dir

RCON.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCONServer", "RCONServer\RC
44
EndProject
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCONServerLib", "RCONServerLib\RCONServerLib.csproj", "{2EFA0311-14CE-414B-9867-FC0D1FF6F6C4}"
66
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RCONServerLib.Tests", "RCONServerLib.Tests\RCONServerLib.Tests.csproj", "{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}"
8+
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
911
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
1820
{2EFA0311-14CE-414B-9867-FC0D1FF6F6C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
1921
{2EFA0311-14CE-414B-9867-FC0D1FF6F6C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
2022
{2EFA0311-14CE-414B-9867-FC0D1FF6F6C4}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}.Release|Any CPU.Build.0 = Release|Any CPU
2127
EndGlobalSection
2228
EndGlobal

RCONServer/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ public static int Main(string[] args)
99
{
1010
var server = new RemoteConServer(IPAddress.Any, 27015) {SendAuthImmediately = true};
1111
server.CommandManager.Add("hello", "", (command, arguments) => { return "world"; });
12-
12+
1313
server.StartListening();
1414
while (true)
1515
{
1616
}
17-
18-
return 0;
17+
// ReSharper disable once FunctionNeverReturns
1918
}
2019
}
2120
}

RCONServer/RCONServer.csproj

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,8 @@
3939
<Reference Include="System.Xml" />
4040
</ItemGroup>
4141
<ItemGroup>
42-
<Compile Include="AsynchronousSocketListener.cs" />
43-
<Compile Include="BinaryReaderExt.cs" />
44-
<Compile Include="BinaryWriterExt.cs" />
45-
<Compile Include="IntExtensions.cs" />
46-
<Compile Include="LocalClient.cs" />
47-
<Compile Include="Program - Copy.cs" />
4842
<Compile Include="Program.cs" />
4943
<Compile Include="Properties\AssemblyInfo.cs" />
50-
<Compile Include="RconPacket.cs" />
51-
<Compile Include="SocketServer.cs" />
52-
<Compile Include="StateObject.cs" />
5344
</ItemGroup>
5445
<ItemGroup>
5546
<ProjectReference Include="..\RCONServerLib\RCONServerLib.csproj">
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("RCONServerLib.Tests")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("RCONServerLib.Tests")]
12+
[assembly: AssemblyCopyright("Copyright © 2018")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// Setting ComVisible to false makes the types in this assembly not visible
17+
// to COM components. If you need to access a type in this assembly from
18+
// COM, set the ComVisible attribute to true on that type.
19+
[assembly: ComVisible(false)]
20+
21+
// The following GUID is for the ID of the typelib if this project is exposed to COM
22+
[assembly: Guid("A1FDCE93-4C35-4A04-AD3E-F67949607BA9")]
23+
24+
// Version information for an assembly consists of the following four values:
25+
//
26+
// Major Version
27+
// Minor Version
28+
// Build Number
29+
// Revision
30+
//
31+
// You can specify all the values or you can default the Build and Revision Numbers
32+
// by using the '*' as shown below:
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{A1FDCE93-4C35-4A04-AD3E-F67949607BA9}</ProjectGuid>
8+
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>RCONServerLib.Tests</RootNamespace>
12+
<AssemblyName>RCONServerLib.Tests</AssemblyName>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<LangVersion>6</LangVersion>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<PlatformTarget>AnyCPU</PlatformTarget>
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<PlatformTarget>AnyCPU</PlatformTarget>
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<OutputPath>bin\Release\</OutputPath>
32+
<DefineConstants>TRACE</DefineConstants>
33+
<ErrorReport>prompt</ErrorReport>
34+
<WarningLevel>4</WarningLevel>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="System" />
38+
<Reference Include="System.Core" />
39+
<Reference Include="System.Data" />
40+
<Reference Include="System.Xml" />
41+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
42+
<HintPath>..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
43+
</Reference>
44+
<Reference Include="xunit.assert, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
45+
<HintPath>..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll</HintPath>
46+
</Reference>
47+
<Reference Include="xunit.core, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
48+
<HintPath>..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll</HintPath>
49+
</Reference>
50+
<Reference Include="xunit.execution.desktop, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c">
51+
<HintPath>..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll</HintPath>
52+
</Reference>
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Compile Include="Properties\AssemblyInfo.cs" />
56+
<Compile Include="Tests.cs" />
57+
</ItemGroup>
58+
<ItemGroup>
59+
<ProjectReference Include="..\RCONServerLib\RCONServerLib.csproj">
60+
<Project>{2efa0311-14ce-414b-9867-fc0d1ff6f6c4}</Project>
61+
<Name>RCONServerLib</Name>
62+
</ProjectReference>
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="packages.config" />
66+
</ItemGroup>
67+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
68+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
69+
Other similar extension points exist, see Microsoft.Common.targets.
70+
<Target Name="BeforeBuild">
71+
</Target>
72+
<Target Name="AfterBuild">
73+
</Target>
74+
-->
75+
</Project>

RCONServerLib.Tests/Tests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using Xunit;
3+
4+
namespace RCONServerLib.Tests
5+
{
6+
public class Tests
7+
{
8+
[Fact]
9+
public void RconPacketLengthTest()
10+
{
11+
Assert.Throws<LengthMismatchException>(() => new RemoteConPacket(new byte[] {0xFF, 0xFF, 0x00, 0x00}));
12+
}
13+
14+
[Fact]
15+
public void RconPacketNullTerminatorEndTest()
16+
{
17+
Assert.Throws<NullTerminatorMissingException>(() => new RemoteConPacket(new byte[]
18+
{
19+
0x0A, 0x00, 0x00, 0x00, // Size
20+
0x00, 0x00, 0x00, 0x00, // Id
21+
0x00, 0x00, 0x00, 0x00, // Type
22+
0x00, // Payload
23+
0x01 // Null-terminator end
24+
}));
25+
}
26+
27+
[Fact]
28+
public void RconPacketTooLongTest()
29+
{
30+
var bytes = new byte[4096];
31+
Array.Copy(new byte[]
32+
{
33+
0xFC, 0x0F, 0x00, 0x00, // Size - 4092
34+
0x00, 0x00, 0x00, 0x00,
35+
0x00, 0x00, 0x00, 0x00
36+
}, 0, bytes, 0, 12);
37+
bytes[4094] = 0x00;
38+
bytes[4095] = 0x00;
39+
for (var i = 13; i < 4094; i++) bytes[i] = 0xFF;
40+
Assert.Throws<NullTerminatorMissingException>(() => new RemoteConPacket(bytes));
41+
}
42+
43+
[Fact]
44+
public void RconPacketTypeTest()
45+
{
46+
Assert.Throws<InvalidPacketTypeException>(() => new RemoteConPacket(new byte[]
47+
{
48+
0x08, 0x00, 0x00, 0x00, // Size
49+
0x00, 0x00, 0x00, 0x00, // Id
50+
0xFF, 0xFF, 0x00, 0x00 // Type
51+
}));
52+
}
53+
}
54+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="OpenCover" version="4.6.519" targetFramework="net452" />
4+
<package id="xunit" version="2.2.0" targetFramework="net452" />
5+
<package id="xunit.abstractions" version="2.0.1" targetFramework="net452" />
6+
<package id="xunit.assert" version="2.2.0" targetFramework="net452" />
7+
<package id="xunit.core" version="2.2.0" targetFramework="net452" />
8+
<package id="xunit.extensibility.core" version="2.2.0" targetFramework="net452" />
9+
<package id="xunit.extensibility.execution" version="2.2.0" targetFramework="net452" />
10+
<package id="xunit.runner.console" version="2.2.0" targetFramework="net452" developmentDependency="true" />
11+
</packages>

RCONServerLib/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Runtime.CompilerServices;
23
using System.Runtime.InteropServices;
34

45
// General Information about an assembly is controlled through the following
@@ -21,6 +22,8 @@
2122
// The following GUID is for the ID of the typelib if this project is exposed to COM
2223
[assembly: Guid("2EFA0311-14CE-414B-9867-FC0D1FF6F6C4")]
2324

25+
[assembly:InternalsVisibleTo("RCONServerLib.Tests")]
26+
2427
// Version information for an assembly consists of the following four values:
2528
//
2629
// Major Version

RCONServerLib/RCONServerLib.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
<Compile Include="Utils\CommandManager.cs" />
5050
<Compile Include="Utils\IpExtension.cs" />
5151
</ItemGroup>
52+
<ItemGroup>
53+
<Content Include="RCONServerLib.nuspec" />
54+
</ItemGroup>
5255
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5356
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5457
Other similar extension points exist, see Microsoft.Common.targets.

0 commit comments

Comments
 (0)