namespace Nonemm.Session.Tests; public class QtcMessagesTests { [Fact] public void ALineIsTheTimeTheCallAndTheSerialNumber() { Assert.Equal( "1234 DL1ABC 123", QtcMessages.Line("1234", "DL1ABC", "123", QtcMessages.DefaultFieldSpacing)); } /// N1MM writes the spacing with `S` for a space, so an operator who wants /// two writes `SS`. [Fact] public void TheSpacingIsWrittenWithSForASpace() { Assert.Equal("1234 DL1ABC 123", QtcMessages.Line("1234", "DL1ABC", "123", "SS")); } [Fact] public void AnythingElseInTheSpacingGoesOutAsItIs() { Assert.Equal("1234/DL1ABC/123", QtcMessages.Line("1234", "DL1ABC", "123", "/")); } /// N1MM lets the TU message name the series it is closing. [Fact] public void TheTuMessageCanCarryTheHeader() { Assert.Equal("TU QTC 3/10 73", QtcMessages.Tu("TU {QTC} 73", "QTC 3/10")); } [Fact] public void ATuMessageWithoutTheHeaderIsLeftAlone() { Assert.Equal("TU 73", QtcMessages.Tu("TU 73", "QTC 3/10")); } /// N1MM joins the three fields with hyphens on RTTY and offers no setting /// for it. [Fact] public void ARttyLineIsTheThreeFieldsJoinedWithHyphens() { Assert.Equal("1234-DL1ABC-123", QtcMessages.RttyLine(" 1234 ", " DL1ABC ", " 123 ")); } /// The shape is N1MM's, from `QTCWindow.cs:3609`: the heading, the spacing, /// then every line with a space and the spacing behind it, then the ending. /// The macros are left for the expander; `{QTC}` is the one filled in here. [Fact] public void SendAllReadsTheWholeSeriesOutInOneMessage() { string message = QtcMessages.SendAll( QtcMessages.DefaultSendAllHeading, QtcMessages.DefaultSendAllEnding, QtcMessages.DefaultRttySpacing, "QTC 3/10", ["1234-DL1ABC-123", "1240-G3XYZ-124"]); Assert.Equal( "{TX}{ENTERLF}QTC 3/10 QTC 3/10{ENTER}" + "1234-DL1ABC-123 {ENTER}" + "1240-G3XYZ-124 {ENTER}" + "{ENTERLF}QSL?? BK DE {MYCALL} K{RX}", message); } [Fact] public void SendAllWithNoLinesSendsNothing() { Assert.Equal( "", QtcMessages.SendAll( QtcMessages.DefaultSendAllHeading, QtcMessages.DefaultSendAllEnding, QtcMessages.DefaultRttySpacing, "QTC 3/10", [])); } /// One line asked for again, which N1MM wraps in the spacing on both sides. [Fact] public void OneLineKeysAndDropsTheTransmitterOfItsOwn() { Assert.Equal( "{TX}{ENTER}1234-DL1ABC-123{ENTER}{RX}", QtcMessages.SendOne(QtcMessages.DefaultRttySpacing, "1234-DL1ABC-123")); } [Fact] public void WhatIsInTheBoxesIsTrimmed() { Assert.Equal( "1234 DL1ABC 123", QtcMessages.Line(" 1234 ", " DL1ABC ", " 123 ", QtcMessages.DefaultFieldSpacing)); } }