Skip to content

Commit

Permalink
test: add test project
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jun 29, 2022
1 parent d3d2711 commit f6cdb02
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 1 deletion.
8 changes: 7 additions & 1 deletion GamingAPIPlugins.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 15.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GamingAPIPlugins", "GamingAPIPlugins\GamingAPIPlugins.csproj", "{E3B20E54-ACFF-4CB1-A5EC-97EB6AB462EF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GamingAPIPlugins", "GamingAPIPlugins\GamingAPIPlugins.csproj", "{E3B20E54-ACFF-4CB1-A5EC-97EB6AB462EF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject2", "UnitTestProject2\UnitTestProject2.csproj", "{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -14,6 +16,10 @@ Global
{E3B20E54-ACFF-4CB1-A5EC-97EB6AB462EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3B20E54-ACFF-4CB1-A5EC-97EB6AB462EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3B20E54-ACFF-4CB1-A5EC-97EB6AB462EF}.Release|Any CPU.Build.0 = Release|Any CPU
{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions GamingAPIPlugins/GamingAPIPlugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,9 @@
<ItemGroup>
<PackageReference Include="Oxide.Ext.GamingApi" Version="0.10.0"/>
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>UnitTestProject2</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>
70 changes: 70 additions & 0 deletions UnitTestProject2/GamingAPIPluginsTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{55C4CE6A-72BA-4EB0-B5FC-64FE1EC58547}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTestProject2</RootNamespace>
<AssemblyName>UnitTestProject2</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.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>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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="Assembly-CSharp">
<HintPath>..\GamingAPIPlugins\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Oxide.Core">
<HintPath>..\GamingAPIPlugins\Managed\Oxide.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.1.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GamingAPIPlugins\GamingAPIPlugins.csproj">
<Project>{e3b20e54-acff-4cb1-a5ec-97eb6ab462ef}</Project>
<Name>GamingAPIPlugins</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
20 changes: 20 additions & 0 deletions UnitTestProject2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("UnitTestProject2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTestProject2")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("55c4ce6a-72ba-4eb0-b5fc-64fe1ec58547")]

// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
27 changes: 27 additions & 0 deletions UnitTestProject2/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Oxide.Plugins;
using System.Reflection;
using System.Collections.Generic;
using ConVar;
using Oxide.Ext.GamingApi.MessageQueue;

namespace Test
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
GamingAPI plugin = new GamingAPI();
MethodInfo methodInfo = typeof(GamingAPI).GetMethod("OnPlayerChat", BindingFlags.NonPublic | BindingFlags.Instance);
var p = new BasePlayer();
p.UserIDString = "test";
p.displayName = "test";
object[] parameters = { p, "test", Chat.ChatChannel.Global };
methodInfo.Invoke(plugin, parameters);
Assert.AreEqual(GamingApiMessageQueue.Instance.GetCurrentMessagesInQueue(), 1);
}
}
}

0 comments on commit f6cdb02

Please sign in to comment.