public void FinalizeReceiveTest() { var data = _rdg.GetRandomData(20).ToList(); var expectedData = new List <byte>(data); IContext context = new Context(); data.AddRange(Enumerable.Repeat(context.Options.SUB, 15)); context.Data = data; IFinalizer finalizer = new FinalizeReceive(); // Test to see if finalizer strips away SUB. finalizer.Finalize(context); Assert.AreEqual(expectedData, context.Data); context.Data = new List <byte>(); // Test to see if finalizer ends safely if no data present. finalizer.Finalize(context); }
private void RunTestForInvokeReceive(IEnumerable <byte> data, XModemMode mode) { var communicator = new ComSendCollection(); IInvoker invoker = new InvokeReceive(); IFinalizer finalizer = new FinalizeReceive(); IContext context = new Context { Mode = mode, Communicator = communicator, }; var packets = context.Tools.Builder.GetPackets(data, context.Options); packets.Add(new List <byte> { context.Options.EOT }); communicator.CollectionToSend = packets; invoker.Invoke(context); finalizer.Finalize(context); Assert.AreEqual(data, context.Data); Assert.AreEqual(packets.GetRange(0, packets.Count - 1), context.Packets); }