Ejemplo n.º 1
0
        public void SetUp()
        {
            _timeModel = Substitute.For <ITimeModel>();
            _timeModel.RealTimeSinceStartup.ReturnsForAnyArgs(0);

            _service = Substitute.For <IMetaService>();
            _service.IsConnected.ReturnsForAnyArgs(true);

            _testModel = new MetaModel(_timeModel, _service, Substitute.For <IUpdateWatcher>());
        }
Ejemplo n.º 2
0
        public MetaService(ITimeModel timeModel, IUpdateWatcher updateWatcher, float?emulateConnectDelay = null, bool emulateDisconnects = false)
        {
            _timeModel           = timeModel;
            _updateWatcher       = updateWatcher;
            _emulateConnectDelay = emulateConnectDelay;
            _emulateDisconnects  = emulateDisconnects;
            _initTime            = _timeModel.RealTimeSinceStartup;

            float startDelay = emulateConnectDelay ?? 0;

            _nextDiscTime = _timeModel.RealTimeSinceStartup + startDelay + Random.Range(3f, 7f);
        }
Ejemplo n.º 3
0
        public ApplicationModel(IMetaModel metaModel, ITimeModel timeModel, ILayersModel layersModel,
                                ISimulationModel simulationModel, IAssetsModel assetsModel, IUpdateWatcher updateWatcher)
        {
            Data                 = new ApplicationModelSharedData();
            Data.AssetsModel     = assetsModel;
            Data.LayersModel     = layersModel;
            Data.MetaModel       = metaModel;
            Data.SimulationModel = simulationModel;
            Data.TimeModel       = timeModel;
            Data.UpdateWatcher   = updateWatcher;

            BecomeContext((x) => x.Data = Data);
            SetNewState(new LoadingLobbyState());
        }
Ejemplo n.º 4
0
        public MainPresenter(IMainView mainView, ITimeModel timeModel,
                             Timer timer, TimeService timeService, ShutdownService shutdownService)
        {
            // Inject các thành phần vào presenter
            this.mainView        = mainView;
            this.timeModel       = timeModel;
            this.timer           = timer;
            this.timeService     = timeService;
            this.shutdownService = shutdownService;

            // Thiết lập 1 chu kì bằng 1 giây
            timer.Interval = 1000;

            // Xử lí các sự kiện
            mainView.Load            += LoadHandler;
            mainView.ShutDownCommand += ShutdownHandler;
            mainView.CancelCommand   += CancelHandler;
            timer.Tick += TickHandler;
        }