Esempio n. 1
0
        public void Setup()
        {
            _fakeSeparationHandler = Substitute.For <ISeperationHandler>();
            _fakeFlightObserver    = Substitute.For <IFlightObserver>();
            var fakeConsole = Substitute.For <IConsole>();
            var fakeLogger  = Substitute.For <Infrastructure.ILogger>();

            _ssut_view = new ConsoleView(fakeConsole);
            _sut       = new AirspaceEventHandler(_fakeFlightObserver, _ssut_view, fakeLogger, _fakeSeparationHandler);
        }
Esempio n. 2
0
        public void SetUp()
        {
            _fakeTimer      = Substitute.For <ITimer>();
            _fakeView       = Substitute.For <IView>();
            _fakeSeperation = Substitute.For <ISeperationHandler>();
            var fakeLogger = Substitute.For <ILogger>();

            _fakeFlightObserver = Substitute.For <IFlightObserver>();
            _uut = new AirspaceEventHandler(_fakeFlightObserver, _fakeView, fakeLogger, _fakeSeperation);
        }
 public AirspaceEventHandler(IFlightObserver flightsInAirspaceSubject, IView view, ILogger logger, ISeperationHandler seperationHandler)
 {
     _flightsInAirspaceSubject = flightsInAirspaceSubject;
     _view = view;
     _seperationHandler = seperationHandler;
     _logger            = logger;
     _flightsInAirspaceSubject.EnteredAirspace += EnterAirspaceEvent;
     _flightsInAirspaceSubject.LeftAirspace    += LeftAirspaceEvent;
     _seperationHandler.FlightsInProximity     += DangerOfProximityEvent;
 }
Esempio n. 4
0
        public void LogOut(Angajat angajat, IFlightObserver observer)
        {
            IFlightObserver localClient = loggedAngajati[angajat.Id];

            if (localClient == null)
            {
                throw new FlightException("Empployee logged out");
            }
            loggedAngajati.Remove(angajat.Id);
        }
Esempio n. 5
0
        private void notifyAll()
        {
            IEnumerable <Angajat> angajati = angajatRepository.FindAll();

            foreach (Angajat a in angajati)
            {
                if (loggedAngajati.ContainsKey(a.Id))
                {
                    IFlightObserver observer = loggedAngajati[a.Id];
                    observer.TicketBought(zborRepository.findAll());
                }
            }
        }
Esempio n. 6
0
 private void closeConnection()
 {
     finished = true;
     try
     {
         stream.Close();
         connection.Close();
         _waitHandle.Close();
         client = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.StackTrace);
     }
 }
Esempio n. 7
0
        public void LogIn(Angajat angajat, IFlightObserver observer)
        {
            Angajat angajat1 = angajatRepository.LogIn(angajat.Id, angajat.Password);

            if (angajat1 != null)
            {
                if (loggedAngajati.ContainsKey(angajat.Id))
                {
                    throw new FlightException("Employee already logged in!");
                }
                loggedAngajati[angajat.Id] = observer;
            }
            else
            {
                throw new FlightException("Autthetication failed!");
            }
        }
Esempio n. 8
0
        public void LogOut(Angajat angajat, IFlightObserver observer)
        {
            sendRequest(new LogoutRequest(angajat));
            Response response = readResponse();

            closeConnection();
            if (response is ErrorResponse)
            {
                ErrorResponse err = (ErrorResponse)response;
                throw new FlightException(err.Message);
            }
            if (response is OkResponse)
            {
                this.client = observer;
                return;
            }
        }
Esempio n. 9
0
        public virtual void LogIn(Angajat angajat, IFlightObserver observer)
        {
            initializeConnection();
            sendRequest(new LoginRequest(angajat));
            Response response = readResponse();

            if (response is OkResponse)
            {
                this.client = observer;
                return;
            }
            if (response is ErrorResponse)
            {
                ErrorResponse err = (ErrorResponse)response;
                closeConnection();
                throw new FlightException(err.Message);
            }
        }
        public void SetUp()
        {
            _fakeFlightObserver = Substitute.For <IFlightObserver>();

            _uut = new SeparationHandler();
        }