Ejemplo n.º 1
0
        public void ViewModelTest()
        {
            // arrange
            var pavlovServers =
                PavlovServerServiceTests.InitializePavlovServer(_sshServerSerivce, _pavlovServerService);
            var pavlovServerInfo =
                PavlovServerInfoServiceTest.CreatePavlovServerInfo(_pavlovServerInfoService, pavlovServers.First().Id);
            var pavlovServerPlayer =
                PavlovServerPlayerServiceTest.CreatePavlovServerPlayer(_pavlovServerPlayerService,
                                                                       pavlovServers.First().Id);

            // act
            var result =
                _publicViewListsService.PavlovServerPlayerListPublicViewModel(pavlovServerInfo,
                                                                              new[] { pavlovServerPlayer });
            var result2 = _publicViewListsService.GetPavlovServerPlayerListPublicViewModel(pavlovServers.First().Id, false)
                          .GetAwaiter().GetResult();

            // assert
            result.ServerInfo.ServerName.Should().Be("test");
            result2.PlayerList.Should().NotBeNull();
            result.PlayerList.Should().NotBeNull();
            result.Should().NotBeNull();
            result2.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        private SteamIdentity InitializeEntryForWhiteList(out PavlovServer[] pavlovServers)
        {
            var user          = ServerSelectedModServiceTests.InsertUserAndSteamIdentity(_steamIdentityService, _userManager);
            var steamIdentity = _steamIdentityService.FindOne(user.Id).GetAwaiter().GetResult();

            pavlovServers = PavlovServerServiceTests.InitializePavlovServer(_sshServerSerivce, _pavlovServerService);
            return(steamIdentity);
        }
        public void FindServer()
        {
            // arrange
            var pavlovServers =
                PavlovServerServiceTests.InitializePavlovServer(_sshServerSerivce, _pavlovServerService);

            CreatePavlovServerInfo(_pavlovServerInfoService, pavlovServers.First().Id);
            // act
            var serverInfoResult =
                _pavlovServerInfoService.FindServer(pavlovServers.First().Id).GetAwaiter().GetResult();

            // assert
            serverInfoResult.Should().NotBeNull();
        }
        public void DeleteSshServer()
        {
            // arrange
            var sshServer = SshServerInsert(_sshServerSerivce);

            sshServer.PavlovServers = PavlovServerServiceTests.PavlovServers(sshServer, _pavlovServerService).ToList();
            sshServer.Should().NotBeNull();
            // act
            _sshServerSerivce.Delete(sshServer.Id).GetAwaiter().GetResult();
            // assert
            var SshServers = _sshServerSerivce.FindAll().GetAwaiter().GetResult();

            SshServers.Should().BeEmpty();
        }
        private static PavlovServer[] InsertToPavlovServer(LiteDbUser user, SshServerSerivce sshServerSerivce,
                                                           PavlovServerService pavlovServerService, ServerSelectedModsService serverSelectedModsService,
                                                           bool withInsert = true)
        {
            var pavlovServers =
                PavlovServerServiceTests.InitializePavlovServer(sshServerSerivce, pavlovServerService);

            if (withInsert)
            {
                serverSelectedModsService.Insert(new ServerSelectedMods
                {
                    LiteDbUser   = user,
                    PavlovServer = pavlovServers.First()
                }).GetAwaiter().GetResult();
            }
            return(pavlovServers);
        }
Ejemplo n.º 6
0
        public void FindAllFromServer()
        {
            // arrange
            var pavlovServers =
                PavlovServerServiceTests.InitializePavlovServer(_sshServerSerivce, _pavlovServerService);
            var serverBan = CreatePavlovServerBans(_serverBansService, pavlovServers.First());
            // act
            var serverResult  = _serverBansService.FindOne(serverBan.Id).GetAwaiter().GetResult();
            var serverResult1 = _serverBansService.FindAll().GetAwaiter().GetResult();
            var serverResult2 = _serverBansService.FindAllFromPavlovServerId(pavlovServers.First().Id, false)
                                .GetAwaiter().GetResult();
            var serverResult3 = _serverBansService.FindAllFromPavlovServerId(pavlovServers.First().Id, true)
                                .GetAwaiter().GetResult();
            var serverResult4 = _serverBansService.Delete(serverBan.Id).GetAwaiter().GetResult();
            var serverResult5 = _serverBansService.FindOne(serverBan.Id).GetAwaiter().GetResult();

            // assert
            serverResult.Should().NotBeNull();
            serverResult1.Should().HaveCount(1);
            serverResult2.Should().HaveCount(1);
            serverResult3.Should().HaveCount(1);
            serverResult4.Should().BeTrue();
            serverResult5.Should().BeNull();
        }
        public void DefaultDB(bool teamMatch)
        {
            // arrange
            var pavlovServers =
                PavlovServerServiceTests.InitializePavlovServer(_sshServerSerivce, _pavlovServerService);

            pavlovServers.First().ServerType = ServerType.Event;
            _pavlovServerService.Upsert(pavlovServers.First());
            var tmpMatch = CreateMatch(_matchService, pavlovServers.First(), teamMatch, _teamService,
                                       _steamIdentityService, _userManager, _matchSelectedSteamIdentitiesService,
                                       _matchSelectedTeamSteamIdentitiesService);

            // act
            var result  = _matchService.FindOne(tmpMatch.Id).GetAwaiter().GetResult();
            var result2 = _matchService.FindAll().GetAwaiter().GetResult();

            result.Status = Status.Finshed;
            _matchService.Upsert(result).GetAwaiter().GetResult();

            if (teamMatch)
            {
                var matchTeamSelectedSteamIdentities =
                    _matchSelectedTeamSteamIdentitiesService.FindAll().GetAwaiter().GetResult();
                //cause i added 2
                matchTeamSelectedSteamIdentities.Should().HaveCount(2);

                var selected = _matchSelectedTeamSteamIdentitiesService.FindAllSelectedForMatchAndTeam(tmpMatch.Id,
                                                                                                       matchTeamSelectedSteamIdentities.First().TeamId).GetAwaiter().GetResult();
                //cause i selected one per team
                selected.Should().HaveCount(1);
                _matchSelectedTeamSteamIdentitiesService.RemoveFromMatch(matchTeamSelectedSteamIdentities.First().Id)
                .GetAwaiter().GetResult();

                matchTeamSelectedSteamIdentities =
                    _matchSelectedTeamSteamIdentitiesService.FindAll().GetAwaiter().GetResult();
                matchTeamSelectedSteamIdentities.Should().BeNullOrEmpty();
            }
            else
            {
                var matchSelectedSteamIdentities =
                    _matchSelectedSteamIdentitiesService.FindAll().GetAwaiter().GetResult();
                matchSelectedSteamIdentities.Should().HaveCount(2);


                matchSelectedSteamIdentities = _matchSelectedSteamIdentitiesService.FindAllSelectedForMatch(tmpMatch.Id)
                                               .GetAwaiter().GetResult();

                matchSelectedSteamIdentities.Should().HaveCount(2);


                _matchSelectedSteamIdentitiesService.RemoveFromMatch(tmpMatch.Id).GetAwaiter().GetResult();

                matchSelectedSteamIdentities = _matchSelectedSteamIdentitiesService.FindAll().GetAwaiter().GetResult();
                //cause i removed 1
                matchSelectedSteamIdentities.Should().BeNullOrEmpty();
            }


            var result3 = _matchService.CanBeDeleted(tmpMatch.Id).GetAwaiter().GetResult();
            var result4 = _matchService.Delete(tmpMatch.Id).GetAwaiter().GetResult();

            var result5 = _matchService.FindOne(tmpMatch.Id).GetAwaiter().GetResult();

            // assert
            result.Should().NotBeNull();
            result2.Should().HaveCount(1);
            result3.Should().BeTrue();
            result4.Should().BeTrue();
            result5.Should().BeNull();
        }