コード例 #1
0
ファイル: QsoStoreTests.cs プロジェクト: rmc47/CompressedLogs
        public void AddQso()
        {
            Qso source = new Qso
            {
                Callsign = "JW1ABC",
                QsoTime = new DateTime (2015, 07, 13, 15, 17, 0),
                Band = Band.B40m,
                Mode = Mode.CW,
                Operator = "M0VFC",
            };

            var store = new QsoStore();
            store.AddQso(source);
        }
コード例 #2
0
        public ActionResult Submit(int qsoCount, string hash)
        {
            if (qsoCount < 1)
                return new HttpStatusCodeResult(400, "Invalid QSO count");
            if (string.IsNullOrWhiteSpace(hash))
                return new HttpStatusCodeResult(400, "Missing hash");

            int length = Request.ContentLength;
            byte[] incomingData = new byte[length];
            using (Stream requestStream = Request.InputStream)
            {
                int pos = 0;
                while (pos < length)
                {
                    pos += requestStream.Read(incomingData, pos, length - pos);
                }
            }

            List<Qso> submittedQsos = new List<Qso>(qsoCount);
            QsoCompressor compressor = new QsoCompressor ();
            int decompressPos = 0;
            for (int i = 0; i < qsoCount; i++)
            {
                submittedQsos.Add(compressor.UncompressQso(incomingData, ref decompressPos));
            }
            if (decompressPos != length)
                return new HttpStatusCodeResult(400, "Length does not match expected length");

            QsoStore store = new QsoStore();
            foreach (Qso q in submittedQsos)
            {
                if (!store.QsoExists(q))
                {
                    store.AddQso(q);
                }
            }
            return Content("OK");
        }
コード例 #3
0
ファイル: QsoStoreTests.cs プロジェクト: rmc47/CompressedLogs
        public void ProcessedTest()
        {
            Qso source = new Qso
            {
                Callsign = "JW1ABC",
                QsoTime = new DateTime(2015, 07, 13, 15, 17, 0),
                Band = Band.B40m,
                Mode = Mode.CW,
                Operator = "M0VFC",
            };

            var store = new QsoStore();
            if (store.QsoExists(source))
                store.DeleteQso(source);

            Assert.IsFalse(store.QsoExists(source));
            store.AddQso(source);
            Assert.IsTrue(store.QsoExists(source));
            int unprocessedCount = store.GetUnprocessedQsos().Count;
            store.MarkQsoProcessed(source);
            int unprocessedCountAfterProcessing = store.GetUnprocessedQsos().Count;
            Assert.AreEqual(unprocessedCount - 1, unprocessedCountAfterProcessing, "Expected unprocessed count to go down after processing");
        }