public void TestInitialise() { _Server = Factory.Singleton.Resolve <IRebroadcastServer>(); _Listener = new Mock <IListener>(MockBehavior.Default) { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _BroadcastProvider = new Mock <IBroadcastProvider>(MockBehavior.Default) { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _SentBytes = new List <byte[]>(); _BroadcastProvider.Setup(r => r.Send(It.IsAny <byte[]>())).Callback((byte[] bytes) => _SentBytes.Add(bytes)); _Server.Listener = _Listener.Object; _Server.BroadcastProvider = _BroadcastProvider.Object; _ExceptionCaughtEvent = new EventRecorder <EventArgs <Exception> >(); _ExceptionCaughtEvent.EventRaised += DefaultExceptionCaughtHandler; _OnlineChangedEvent = new EventRecorder <EventArgs>(); _Server.ExceptionCaught += _ExceptionCaughtEvent.Handler; _Server.OnlineChanged += _OnlineChangedEvent.Handler; _Port30003Message = new BaseStationMessage() { Icao24 = "313233" }; }
/// <summary> /// Disposes of the server and the associated broadcast provider. /// </summary> /// <param name="server"></param> private void ReleaseServer(IRebroadcastServer server) { var connector = server.Connector; server.Dispose(); connector.ConnectionEstablished -= Connector_ClientConnected; connector.ConnectionClosed -= Connector_ClientDisconnected; connector.Dispose(); }
/// <summary> /// Disposes of the server and the associated broadcast provider. /// </summary> /// <param name="server"></param> private void ReleaseServer(IRebroadcastServer server) { var broadcastProvider = server.BroadcastProvider; server.Dispose(); broadcastProvider.BroadcastSent -= BroadcastProvider_BroadcastSent; broadcastProvider.ClientConnected -= BroadcastProvider_ClientConnected; broadcastProvider.ClientDisconnected -= BroadcastProvider_ClientDisconnected; broadcastProvider.ExceptionCaught -= BroadcastProvider_ExceptionCaught; broadcastProvider.Dispose(); }
public void TestInitialise() { _OriginalFactory = Factory.TakeSnapshot(); _Clock = new ClockMock(); _Timer = TestUtilities.CreateMockImplementation <ITimer>(); _Compressor = TestUtilities.CreateMockImplementation <IBaseStationMessageCompressor>(); _Server = Factory.Resolve <IRebroadcastServer>(); _Feed = TestUtilities.CreateMockInstance <IFeed>(); _Listener = TestUtilities.CreateMockInstance <IListener>(); _Feed.SetupGet(r => r.Listener).Returns(_Listener.Object); _Connector = new MockConnector <INetworkConnector, INetworkConnection>(); _AircraftListJsonBuilder = TestUtilities.CreateMockImplementation <IAircraftListJsonBuilder>(); _AircraftListJson = new AircraftListJson(); _AircraftListJsonBuilderArgs = null; _IgnoreInvisibleFeeds = null; _FallbackToDefault = null; _AircraftListJsonBuilder.Setup(r => r.Build(It.IsAny <AircraftListJsonBuilderArgs>(), It.IsAny <bool>(), It.IsAny <bool>())).Callback((AircraftListJsonBuilderArgs args, bool ignoreInvisibleFeeds, bool fallbackToDefault) => { _AircraftListJsonBuilderArgs = args; _IgnoreInvisibleFeeds = ignoreInvisibleFeeds; _FallbackToDefault = fallbackToDefault; }).Returns(_AircraftListJson); _AircraftList = TestUtilities.CreateMockImplementation <IBaseStationAircraftList>(); _Feed.SetupGet(r => r.AircraftList).Returns(_AircraftList.Object); _SnapshotAircraft = new List <IAircraft>(); long of1, of2; _AircraftList.Setup(m => m.TakeSnapshot(out of1, out of2)).Returns(_SnapshotAircraft); _Server.UniqueId = 1; _Server.Name = "It's the code word"; _Server.Format = RebroadcastFormat.Port30003; _Server.Feed = _Feed.Object; _Server.Connector = _Connector.Object; _ExceptionCaughtEvent = new EventRecorder <EventArgs <Exception> >(); _ExceptionCaughtEvent.EventRaised += DefaultExceptionCaughtHandler; _OnlineChangedEvent = new EventRecorder <EventArgs>(); _Server.ExceptionCaught += _ExceptionCaughtEvent.Handler; _Server.OnlineChanged += _OnlineChangedEvent.Handler; _Port30003Message = new BaseStationMessage() { Icao24 = "313233" }; }
public void TestInitialise() { _Server = Factory.Singleton.Resolve<IRebroadcastServer>(); _Listener = new Mock<IListener>(MockBehavior.Default) { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _BroadcastProvider = new Mock<IBroadcastProvider>(MockBehavior.Default) { DefaultValue = DefaultValue.Mock }.SetupAllProperties(); _SentBytes = new List<byte[]>(); _BroadcastProvider.Setup(r => r.Send(It.IsAny<byte[]>())).Callback((byte[] bytes) => _SentBytes.Add(bytes)); _Server.Listener = _Listener.Object; _Server.BroadcastProvider = _BroadcastProvider.Object; _ExceptionCaughtEvent = new EventRecorder<EventArgs<Exception>>(); _ExceptionCaughtEvent.EventRaised += DefaultExceptionCaughtHandler; _OnlineChangedEvent = new EventRecorder<EventArgs>(); _Server.ExceptionCaught += _ExceptionCaughtEvent.Handler; _Server.OnlineChanged += _OnlineChangedEvent.Handler; _Port30003Message = new BaseStationMessage() { Icao24 = "313233" }; }
private void ConfigureAuthentication(RebroadcastSettings rebroadcastSettings, IRebroadcastServer server) { var existingAuthentication = server.Connector.Authentication as IPassphraseAuthentication; var passphrase = rebroadcastSettings.Passphrase ?? ""; if ((existingAuthentication == null && passphrase != "") || (existingAuthentication != null && existingAuthentication.Passphrase != passphrase)) { if (passphrase == "") { server.Connector.Authentication = null; } else { var authentication = Factory.Singleton.Resolve <IPassphraseAuthentication>(); authentication.Passphrase = rebroadcastSettings.Passphrase; server.Connector.Authentication = authentication; } } }