예제 #1
0
        public void ParseLogConnectedTest()
        {
            // arrange
            var         channel         = new SvxlinkChannel();
            ChannelBase returnedChannel = null;

            var service = Substitute.ForPartsOf <SvxLinkService>(logger, repositories, scanService, telemetry, iniService);

            service.Connected += c => returnedChannel = c;

            // act
            service.ParseLog(channel, "ReflectorLogic: Connected nodes: EXPERIMENTAL, (25) F1POK H, (25) F1POK V, ( M) F1POK H, (05) F5HII H, (27) F6DSB V, (CH) HB9GVE H, (CH) HB9GXP H");

            // assert
            Assert.AreEqual(channel, returnedChannel);
            Assert.AreEqual(8, service.Nodes.Count);
        }
예제 #2
0
        public void ParseLogNodeConnectedTest()
        {
            // arrange
            var  channel = new SvxlinkChannel();
            Node node    = null;

            var service = Substitute.ForPartsOf <SvxLinkService>(logger, repositories, scanService, telemetry, iniService);

            service.NodeConnected += (n) => node = n;

            // act
            service.ParseLog(channel, "ReflectorLogic: Node joined: (CH) HB9GXP H");

            // assert
            Assert.AreEqual(node.Name, " (CH) HB9GXP H");
            Assert.AreEqual(1, service.Nodes.Count);
        }
예제 #3
0
        public void ActivateSvxlinkChannelDefaultCallTest()
        {
            // arrange
            repositories.ScanProfiles.Get(1).Returns(new ScanProfile {
                ScanDelay = 1000
            });
            var service = Substitute.ForPartsOf <TestableSvxlinkService>(logger, repositories, scanService, telemetry, iniService);

            service.When(x => x.StopSvxlink()).DoNotCallBase();
            var channel = new SvxlinkChannel {
                CallSign = "(CH) SVX4LINK H", Host = "google.fr", Port = 80
            };

            // act
            service.ActivateSvxlinkChannel(channel);

            // assert
            service.Received(1).StopSvxlink();
        }
예제 #4
0
        public void ActivateSvxlinkChannelTest()
        {
            // arrange
            repositories.ScanProfiles.Get(1).Returns(new ScanProfile {
                ScanDelay = 1000
            });
            var radioProfile = new RadioProfile {
                RxCtcss = "0002"
            };

            repositories.RadioProfiles.GetCurrent().Returns(radioProfile);

            var service = Substitute.ForPartsOf <TestableSvxlinkService>(logger, repositories, scanService, telemetry, iniService);

            service.When(x => x.StopSvxlink()).DoNotCallBase();
            service.When(x => x.StartSvxLink(Arg.Any <SvxlinkChannel>())).DoNotCallBase();
            var channel = new SvxlinkChannel {
                CallSign = "(CH) HB9GXP H", Host = "google.fr", Port = 80
            };

            Predicate <Dictionary <string, Dictionary <string, string> > > isParametersOk = x =>
            {
                return(x["GLOBAL"]["LOGICS"] == "SimplexLogic,ReflectorLogic" &&
                       x["SimplexLogic"]["MODULES"] == "ModuleHelp,ModuleMetarInfo,ModulePropagationMonitor" &&
                       x["SimplexLogic"]["CALLSIGN"] == channel.ReportCallSign &&
                       x["SimplexLogic"]["REPORT_CTCSS"] == radioProfile.RxTone &&
                       x["Rx1"]["SQL_DET"] == radioProfile.SquelchDetection &&
                       x["ReflectorLogic"]["CALLSIGN"] == channel.CallSign &&
                       x["ReflectorLogic"]["HOST"] == channel.Host &&
                       x["ReflectorLogic"]["AUTH_KEY"] == channel.AuthKey &&
                       x["ReflectorLogic"]["PORT"] == channel.Port.ToString());
            };

            // act
            service.ActivateSvxlinkChannel(channel);

            // assert
            service.Received(1).StopSvxlink();
            iniService.Received(1).ReplaceConfig($"{service.applicationPath}/SvxlinkConfig/svxlink.conf", Arg.Is <Dictionary <string, Dictionary <string, string> > >(x => isParametersOk(x)));
            service.Received(1).Protected("ReplaceSoundFile", channel);
            service.Received(1).StartSvxLink(channel);
        }
예제 #5
0
        public void ParseLogNodeDisconnectedTest()
        {
            // arrange
            var  channel = new SvxlinkChannel();
            Node node    = null;

            var service = Substitute.ForPartsOf <SvxLinkService>(logger, repositories, scanService, telemetry, iniService);

            service.NodeDisconnected += (n) => node = n;
            service.Nodes.Add(new Node {
                Name = " (CH) HB9GXP H"
            });

            // act
            service.ParseLog(channel, "ReflectorLogic: Node left: (CH) HB9GXP H");

            // assert
            Assert.AreEqual(node.Name, " (CH) HB9GXP H");
            Assert.IsEmpty(service.Nodes);
        }
예제 #6
0
        public void StartDefaultChannelTest()
        {
            // arrange
            var channel = new SvxlinkChannel {
                Id = 300
            };

            repositories.Channels.GetDefault().Returns(channel);

            var service = Substitute.ForPartsOf <TestableSvxlinkService>(logger, repositories, scanService, telemetry, iniService);

            service.When(x => x.ActivateChannel(Arg.Any <int>())).DoNotCallBase();

            // act
            service.StartDefaultChannel();

            // assert
            Assert.AreEqual(service.ChannelId, channel.Id);
            service.Received(1).ActivateChannel(channel.Id);
        }
예제 #7
0
        public void ParseLogAccessDeniedTest()
        {
            // arrange
            var channel = new SvxlinkChannel {
                Name = "Default"
            };
            string message = null;

            var service = Substitute.ForPartsOf <SvxLinkService>(logger, repositories, scanService, telemetry, iniService);

            service.Nodes.Add(new Node {
                Name = " (CH) HB9GXP H"
            });
            service.Error += (t, m) => message = m;

            // act
            service.ParseLog(channel, "Access denied");

            // assert
            Assert.AreEqual(message, $"Impossible de se connecter au salon {channel.Name}. <br/> Accès refusé.");
        }