IW4M-Admin/Tests/ApplicationTests/ClientTests.cs

72 lines
2.2 KiB
C#
Raw Normal View History

using ApplicationTests.Fixtures;
using FakeItEasy;
using IW4MAdmin;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
using SharedLibraryCore;
using SharedLibraryCore.Database.Models;
using System;
using System.Collections.Generic;
using System.Text;
2020-11-12 20:46:17 -05:00
using SharedLibraryCore.Configuration;
namespace ApplicationTests
{
[TestFixture]
public class ClientTests
{
private IServiceProvider serviceProvider;
[SetUp]
public void Setup()
{
serviceProvider = new ServiceCollection()
.BuildBase()
.BuildServiceProvider();
}
#region KICK
[Test]
public void Test_Kick_Happy()
{
var server = serviceProvider.GetRequiredService<IW4MServer>();
var target = ClientGenerators.CreateBasicClient(server);
var origin = ClientGenerators.CreateBasicClient(server);
origin.Level = EFClient.Permission.Owner;
var result = target.Kick("test", origin);
Assert.False(result.Failed);
Assert.AreEqual(EFClient.ClientState.Disconnecting, target.State);
}
[Test]
public void Test_Kick_FailSamePermission()
{
var server = serviceProvider.GetRequiredService<IW4MServer>();
var target = ClientGenerators.CreateBasicClient(server);
var origin = ClientGenerators.CreateBasicClient(server);
var result = target.Kick("test", origin);
Assert.True(result.Failed);
Assert.AreEqual(GameEvent.EventFailReason.Permission, result.FailReason);
}
[Test]
public void Test_Kick_FailLessPermission()
{
var server = serviceProvider.GetRequiredService<IW4MServer>();
var target = ClientGenerators.CreateBasicClient(server);
var origin = ClientGenerators.CreateBasicClient(server);
target.Level = EFClient.Permission.Owner;
var result = target.Kick("test", origin);
Assert.True(result.Failed);
Assert.AreEqual(GameEvent.EventFailReason.Permission, result.FailReason);
}
#endregion
}
}