示例#1
0
        public void LoginByUsername_UsesDataFromRestServiceToCreateSession()
        {
            const string url      = "http://localhost";
            const string userId   = "userId";
            const string teamId   = "teamId";
            const string teamGuid = "teamGuid";
            const string username = "******";
            const string password = "******";
            var          token    = "token";
            var          login    = new Login {
                LoginId = username, Password = password, Token = string.Empty
            };
            var initialLoad = new InitialLoad {
                Teams = new[] { new Team {
                                    Id = teamGuid, Name = teamId
                                } }
            };
            var user = new User {
                Id = userId
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetInitialLoad(new Uri(url), token)).Returns(initialLoad);
            restService.Setup(x => x.Login(new Uri(url), login, out token)).Returns(user);
            var session     = new Mock <ISession>();
            var chatFactory = new Mock <IChatFactory>();

            chatFactory.Setup(x => x.NewInstance(restService.Object, new Uri(url), token, userId, teamGuid))
            .Returns(session.Object);
            var sut = new ClientImpl(restService.Object, chatFactory.Object);

            var result = sut.LoginByUsername(url, teamId, username, password);

            result.ShouldBeEquivalentTo(session.Object, "because the correct session should be returned");
        }
示例#2
0
        private void sendInitialLoad(int toClient)
        {
            Dictionary <int, Player>    players    = gameManager.players;
            Dictionary <int, Character> characters = gameManager.characters;

            List <PlayerJoinEvent> playerJoinEvents = new List <PlayerJoinEvent>();

            foreach (Player player in players.Values)
            {
                playerJoinEvents.Add(new PlayerJoinEvent(player.playerId, player.username));
            }

            List <CharacterSpawnEvent> spawnCharacterEvents = new List <CharacterSpawnEvent>();

            foreach (Character character in characters.Values)
            {
                spawnCharacterEvents.Add(new CharacterSpawnEvent(character.owningPlayerId, character.id, character.position));
            }

            InitialLoad initialLoad = new InitialLoad(playerJoinEvents, spawnCharacterEvents, gameManager.MAP_SIZE);

            using (Packet _packet = new Packet((int)PacketTypes.ServerPackets.INITIAL_LOAD))
            {
                initialLoad.ToPacket(_packet);
                SendTCPData(toClient, _packet);
            }
        }
示例#3
0
        public void LoginByUsername_ThrowsChatException_IfSettingsTeamIdDoesNotMatchInitialLoadTeamId()
        {
            const string teamIdThatDoesNotMatchSettingsTeamId = "teamIdThatDoesNotMatch";
            const string SettingsTeamId = "settingsTeamId";
            const string url            = "http://localhost";
            const string userId         = "userId";
            const string teamGuid       = "teamGuid";
            const string username       = "******";
            const string password       = "******";
            var          token          = "token";
            var          login          = new Login {
                LoginId = username, Password = password, Token = string.Empty
            };
            var initialLoad = new InitialLoad {
                Teams = new[] { new Team {
                                    Id = teamGuid, Name = teamIdThatDoesNotMatchSettingsTeamId
                                } }
            };
            var user = new User {
                Id = userId
            };
            var restService = new Mock <IRestService>();

            restService.Setup(x => x.GetInitialLoad(new Uri(url), token)).Returns(initialLoad);
            restService.Setup(x => x.Login(new Uri(url), login, out token)).Returns(user);
            var session     = new Mock <ISession>();
            var chatFactory = new Mock <IChatFactory>();

            chatFactory.Setup(x => x.NewInstance(restService.Object, new Uri(url), token, userId, teamGuid)).Returns(session.Object);
            var sut = new ClientImpl(restService.Object, chatFactory.Object);

            NUnit.Framework.Constraints.ActualValueDelegate <ISession> performLogin = () => sut.LoginByUsername(url, SettingsTeamId, username, password);

            Assert.That(performLogin, Throws.TypeOf <ChatException>());
        }
示例#4
0
        public static void Main(string[] args)
        {
            var host = CreateWebHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;
                try
                {
                    var serviceProvider = services.GetRequiredService <IServiceProvider>();
                    var configuration   = services.GetRequiredService <IConfiguration>();
                    var context         = services.GetRequiredService <MetaBookAPIContext>();

                    // Create the base classes and such for data.
                    try
                    {
                        InitialLoad.Initialize(context);
                    }
                    catch (Exception exc)
                    {
                        var logger = services.GetRequiredService <ILogger <Program> >();
                        logger.LogError(exc, "Initial loader has failed to seed. Damn you, loader. Maybe you were already okay?? I HOPE YOU WERE, DAMMIT.");
                    }
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error has occurred.");
                }
            }

            host.Run();
        }
示例#5
0
        public void OnInitialLoad(InitialLoad initialLoad)
        {
            foreach (PlayerJoinEvent evnt in initialLoad.players)
            {
                OnPlayerJoined(evnt);
            }

            foreach (CharacterSpawnEvent evnt in initialLoad.characters)
            {
                OnCharacterSpawn(evnt);
            }
        }
示例#6
0
        public LoginViewModel(InitialLoad initialLoad, Table_Config table_Config)
        {
            DBHelper = new Services.DataHelper();

            GetFingerPrintAvailable();

            if (initialLoad.IsSuccess)
            {
                if (initialLoad.HasConfigData)
                {
                    #region Set UI & Global Data
                    this.UIIsVisible      = true;
                    this.UIErrorIsVisible = false;
                    this.IsChecked        = table_Config.FingerPrintAllow;
                    this.UrlDomain        = table_Config.UrlDomain;
                    this.UrlPrefix        = table_Config.UrlPrefix;
                    this.IsEnabled        = true;
                    #endregion

                    if (IsChecked)
                    {
                        this.IsVisibleFingerPrint = true;
                        this.IsVisibleLogin       = false;
                    }
                    else
                    {
                        this.IsVisibleFingerPrint = false;
                        this.IsVisibleLogin       = true;
                    }
                }
                else
                {
                    Alert.Show("Aplicación sin configuración!");
                }
            }
            else
            {
                this.UIIsVisible      = false;
                this.UIErrorIsVisible = true;
            }
        }
示例#7
0
        public MainViewModel()
        {
            instance = this;
            InitialLoad  initialLoad  = new InitialLoad();
            DataHelper   dbHelper     = new DataHelper();
            Table_Config table_Config = null;

            if (!dbHelper.CreateTablesAndInitialData())
            {
                initialLoad.IsSuccess = false;
            }
            else
            {
                initialLoad.IsSuccess = true;
                table_Config          = dbHelper.GetAppConfig();
                if (table_Config != null)
                {
                    initialLoad.HasConfigData = true;
                }
                else
                {
                    initialLoad.HasConfigData = false;
                }
            }

            this.Login    = new LoginViewModel(initialLoad, table_Config);
            this.Home     = new HomeViewModel();
            this.Settings = new SettingsViewModel();
            this.StatisticalReportsMenu = new StatisticalReportsMenuViewModel();
            this.About                               = new AboutViewModel();
            this.LotAndCommand                       = new LotAndCommandViewModel(false);
            this.LogExecutionDelay                   = new LogExecutionDelayViewModel(false);
            this.LogExecution                        = new LogExecutionViewModel(false);
            this.LogExecutionReport                  = new LogExecutionReportViewModel(false, new ObservableCollection <LogExecutionReportItem>());
            this.LogExecutionChart                   = new LogExecutionChartViewModel(false, new List <LogExecutionResult>());
            this.PlannerMenu                         = new PlannerMenuViewModel();
            this.MonitoringAndExecutionMenu          = new MonitoringAndExecutionMenuViewModel();
            this.OperationsLog                       = new OperationsLogViewModel(false);
            this.ProcessMonitor                      = new ProcessMonitorViewModel(false);
            this.RecurrenceMonitor                   = new RecurrenceMonitorViewModel(false);
            this.StatusInfoPlanner                   = new StatusInfoPlannerViewModel();
            this.Notifications                       = new NotificationsViewModel(false, new Models.LogItem());
            this.InstanceNotifications               = new InstanceNotificationsViewModel(new Models.InstanceItem());
            this.Monitoring                          = new MonitoringViewModel();
            this.Execution                           = new ExecutionViewModel(false, false);
            this.ExecutionStageTwo                   = new ExecutionStageTwoViewModel(false, new Models.LogItem());
            this.ExecutionStageThree                 = new ExecutionStageThreeViewModel(false, new Models.InstanceItem());
            this.CommandNotifications                = new CommandNotificationsViewModel(new Models.CommandItem());
            this.LogObservations                     = new LogObservationsViewModel(false, new LotAndCommandObservation(), new Models.LogItem());
            this.OperatorChange                      = new OperatorChangeViewModel(false, new Models.LogItem());
            this.ControlSchedulesExecution           = new ControlSchedulesExecutionViewModel(false, new Models.LogItem());
            this.StatusInfoControlSchedulesExecution = new StatusInfoControlSchedulesExecutionViewModel();
            this.LogInquiries                        = new LogInquiriesViewModel(false, new Models.LogItem());
            this.LogInquirieDetail                   = new LogInquirieDetailViewModel(new Models.ResultLogInquirieItem());
            this.ControlSchedulesExecutionDetail     = new ControlSchedulesExecutionDetailViewModel(new Models.CommandsToControl());
            this.BatchQuery                          = new BatchQueryViewModel(false, new Models.CommandItem());
            this.EditParameters                      = new EditParametersViewModel(new Models.CommandItem());
            this.StatusInfoExecutionStageTwo         = new StatusInfoExecutionStageTwoViewModel();
            this.StatusInfoExecutionStageThree       = new StatusInfoExecutionStageThreeViewModel();
            this.StatusInfoLogInquiries              = new StatusInfoLogInquiriesViewModel();
            this.Dependencies                        = new DependenciesViewModel(false, new Models.CommandItem());
            this.StatusInfoDependencies              = new StatusInfoDependenciesViewModel();
            this.LotAndCommandReport                 = new LotAndCommandReportViewModel(false, new ObservableCollection <LotAndCommandReportItem>());
            this.LotAndCommandChart                  = new LotAndCommandChartViewModel(false, new List <LotAndCommandResult>());
            this.LogExecutionDelayReport             = new LogExecutionDelayReportViewModel(false, new ObservableCollection <LogExecutionDelayReportItem>());
            this.LogExecutionDelayChart              = new LogExecutionDelayChartViewModel(false, new List <LogExecutionDelayResult>());
            this.OperationsLogReport                 = new OperationsLogReportViewModel(false, new ObservableCollection <OperationsLogReportItem>());
            this.CommandData                         = new CommandDataViewModel(false, new Models.CommandItem());
            this.Result                              = new ResultViewModel(false, new Models.CommandItem());
        }
示例#8
0
    public void onReceiveInitialLoad(Packet packet)
    {
        InitialLoad initialLoad = new InitialLoad(packet);

        connectionManager.onReceiveInitialLoad(initialLoad);
    }
示例#9
0
 public static string SerializeToPayload(this InitialLoad initialLoad)
 {
     return
         ("{\"teams\":[" + string.Join(",", initialLoad.Teams.Select(x => x.SerializeToPayload())) +
          "]}");
 }
示例#10
0
 public void onReceiveInitialLoad(InitialLoad initialLoad)
 {
     GameManager.instance.OnInitialLoad(initialLoad);
 }