mirror of
https://github.com/sochix/TLSharp.git
synced 2026-04-06 06:55:06 +00:00
Tests: add NUnit support
What's an open source project that cannot be tested in an open source platform? The best open source .NET IDE that works in Linux (MonoDevelop) doesn't have support for VisualStudio Testing framework, but it has support for NUnit. By abstracting a bit the TLSharp.Tests assembly we can have two different wrappers, one for NUnit tests and other for VisualStudio tests, so no one can be left behind.
This commit is contained in:
parent
ca78532b34
commit
d6887a70f1
9 changed files with 384 additions and 63 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.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>
|
||||
|
|
@ -8,14 +9,8 @@
|
|||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TLSharp.Tests</RootNamespace>
|
||||
<AssemblyName>TLSharp.Tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</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>
|
||||
|
|
@ -38,18 +33,6 @@
|
|||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
</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="TLSharpTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
@ -73,25 +56,6 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</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.
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using TeleSharp.TL;
|
||||
using TeleSharp.TL.Messages;
|
||||
using TLSharp.Core;
|
||||
|
|
@ -17,7 +15,6 @@ using TLSharp.Core.Utils;
|
|||
|
||||
namespace TLSharp.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class TLSharpTests
|
||||
{
|
||||
private string NumberToSendMessage { get; set; }
|
||||
|
|
@ -38,9 +35,27 @@ namespace TLSharp.Tests
|
|||
|
||||
private int ApiId { get; set; }
|
||||
|
||||
[TestInitialize]
|
||||
public void Init()
|
||||
class Assert
|
||||
{
|
||||
static internal void IsNotNull(object obj)
|
||||
{
|
||||
IsNotNullHanlder(obj);
|
||||
}
|
||||
|
||||
static internal void IsTrue(bool cond)
|
||||
{
|
||||
IsTrueHandler(cond);
|
||||
}
|
||||
}
|
||||
|
||||
internal static Action<object> IsNotNullHanlder;
|
||||
internal static Action<bool> IsTrueHandler;
|
||||
|
||||
protected void Init(Action<object> notNullHandler, Action<bool> trueHandler)
|
||||
{
|
||||
IsNotNullHanlder = notNullHandler;
|
||||
IsTrueHandler = trueHandler;
|
||||
|
||||
// Setup your API settings and phone numbers in app.config
|
||||
GatherTestConfiguration();
|
||||
}
|
||||
|
|
@ -97,8 +112,7 @@ namespace TLSharp.Tests
|
|||
Debug.WriteLine(appConfigMsgWarning, nameof(NumberToAddToChat));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task AuthUser()
|
||||
public virtual async Task AuthUser()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -127,8 +141,7 @@ namespace TLSharp.Tests
|
|||
Assert.IsTrue(client.IsUserAuthorized());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SendMessageTest()
|
||||
public virtual async Task SendMessageTest()
|
||||
{
|
||||
NumberToSendMessage = ConfigurationManager.AppSettings[nameof(NumberToSendMessage)];
|
||||
if (string.IsNullOrWhiteSpace(NumberToSendMessage))
|
||||
|
|
@ -160,8 +173,7 @@ namespace TLSharp.Tests
|
|||
await client.SendMessageAsync(new TLInputPeerUser() { user_id = user.id }, "TEST");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SendMessageToChannelTest()
|
||||
public virtual async Task SendMessageToChannelTest()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -176,8 +188,7 @@ namespace TLSharp.Tests
|
|||
await client.SendMessageAsync(new TLInputPeerChannel() { channel_id = chat.id, access_hash = chat.access_hash.Value }, "TEST MSG");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SendPhotoToContactTest()
|
||||
public virtual async Task SendPhotoToContactTest()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -194,8 +205,7 @@ namespace TLSharp.Tests
|
|||
await client.SendUploadedPhoto(new TLInputPeerUser() { user_id = user.id }, fileResult, "kitty");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SendBigFileToContactTest()
|
||||
public virtual async Task SendBigFileToContactTest()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -218,8 +228,7 @@ namespace TLSharp.Tests
|
|||
new TLVector<TLAbsDocumentAttribute>());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task DownloadFileFromContactTest()
|
||||
public virtual async Task DownloadFileFromContactTest()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -257,9 +266,7 @@ namespace TLSharp.Tests
|
|||
Assert.IsTrue(resFile.bytes.Length > 0);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public async Task DownloadFileFromWrongLocationTest()
|
||||
public virtual async Task DownloadFileFromWrongLocationTest()
|
||||
{
|
||||
var client = NewClient();
|
||||
|
||||
|
|
@ -287,8 +294,7 @@ namespace TLSharp.Tests
|
|||
Assert.IsTrue(resFile.bytes.Length > 0);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SignUpNewUser()
|
||||
public virtual async Task SignUpNewUser()
|
||||
{
|
||||
var client = NewClient();
|
||||
await client.ConnectAsync();
|
||||
|
|
@ -304,8 +310,7 @@ namespace TLSharp.Tests
|
|||
Assert.IsNotNull(loggedInUser);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task CheckPhones()
|
||||
public virtual async Task CheckPhones()
|
||||
{
|
||||
var client = NewClient();
|
||||
await client.ConnectAsync();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue