Exemplo n.º 1
0
        public void ReportClientShouldSucceed()
        {
            while (!Manager.IsInitialized)
            {
                Thread.Sleep(100);
            }

            var client = Manager.Servers.First().GetClientsAsList().FirstOrDefault();

            Assert.False(client == null, "no client found to report");

            // fail
            var player = new EFClient()
            {
                ClientId = 1, Level = EFClient.Permission.Console, CurrentServer = client.CurrentServer
            };

            player.SetAdditionalProperty("_reportCount", 3);
            var reportEvent = client.Report("test report", player);

            reportEvent.OnProcessed.Wait(TestTimeout);

            Assert.True(reportEvent.FailReason == GameEvent.EventFailReason.Throttle &
                        client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId) == 0, $"too many reports were applied [{reportEvent.FailReason.ToString()}]");

            // succeed
            reportEvent = client.Report("test report", new EFClient()
            {
                ClientId = 1, Level = EFClient.Permission.Console, CurrentServer = client.CurrentServer
            });
            reportEvent.OnProcessed.Wait(TestTimeout);

            Assert.True(!reportEvent.Failed &&
                        client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId) == 1, $"report was not applied [{reportEvent.FailReason.ToString()}]");

            // fail
            reportEvent = client.Report("test report", new EFClient()
            {
                ClientId = 1, NetworkId = 1, Level = EFClient.Permission.Banned, CurrentServer = client.CurrentServer
            });

            Assert.True(reportEvent.FailReason == GameEvent.EventFailReason.Permission &&
                        client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId) == 1,
                        $"report was applied without proper permission [{reportEvent.FailReason.ToString()},{ client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId)}]");

            // fail
            reportEvent = client.Report("test report", client);

            Assert.True(reportEvent.FailReason == GameEvent.EventFailReason.Invalid &&
                        client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId) == 1, $"report was applied to self");

            // fail
            reportEvent = client.Report("test report", new EFClient()
            {
                ClientId = 1, Level = EFClient.Permission.Console, CurrentServer = client.CurrentServer
            });

            Assert.True(reportEvent.FailReason == GameEvent.EventFailReason.Exception &&
                        client.CurrentServer.Reports.Count(r => r.Target.NetworkId == client.NetworkId) == 1, $"duplicate report was applied");
        }
Exemplo n.º 2
0
        public void SetAdditionalPropertyShouldSucceed()
        {
            var client  = new EFClient();
            int newProp = 5;

            client.SetAdditionalProperty("NewProp", newProp);
        }
Exemplo n.º 3
0
        public void GetAdditionalPropertyShouldSucceed()
        {
            var client  = new EFClient();
            int newProp = 5;

            client.SetAdditionalProperty("NewProp", newProp);

            Assert.True(client.GetAdditionalProperty <int>("NewProp") == 5, "added property does not match retrieved property");
        }