using System.Text; namespace Nonemm.Rig.Tests; public class OtrspBoxTests { private static string Written(MemoryStream stream) => Encoding.ASCII.GetString(stream.ToArray()); [Fact] public async Task PointingTheTransmitterNamesTheRadio() { MemoryStream sent = new(); using OtrspBox box = new(sent); await box.SetTransmitAsync(2); Assert.Equal("TX2\r", Written(sent)); } [Fact] public async Task ListeningToBothRadiosAddsTheStereoFlag() { MemoryStream sent = new(); using OtrspBox box = new(sent); await box.SetReceiveAsync(1, bothRadios: true); Assert.Equal("RX1S\r", Written(sent)); } /// A box works relays. Saying the same thing again would rattle them for /// nothing, so it is not said. [Fact] public async Task TheSameCommandIsNotSentTwice() { MemoryStream sent = new(); using OtrspBox box = new(sent); await box.SetTransmitAsync(1); await box.SetTransmitAsync(1); await box.SetTransmitAsync(2); Assert.Equal("TX1\rTX2\r", Written(sent)); } [Fact] public async Task TransmitAndReceiveAreTrackedApart() { MemoryStream sent = new(); using OtrspBox box = new(sent); await box.SetTransmitAsync(1); await box.SetReceiveAsync(1); Assert.Equal("TX1\rRX1\r", Written(sent)); } [Fact] public async Task AnAuxiliaryCodeIsSentAsTwoDigits() { MemoryStream sent = new(); using OtrspBox box = new(sent); await box.SetAuxiliaryAsync(2, 3); Assert.Equal("AUX203\r", Written(sent)); } }