Пример #1
0
        public void InitializeFixedObjectFileStreamTest()
        {
            Stream s = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(s);

            Assert.IsTrue(File.Exists(FixedObjectFileStream.TempStreamFile), "FixedObjectFileStream temporary file creation failed");
            instance.Dispose();
            Assert.IsFalse(File.Exists(FixedObjectFileStream.TempStreamFile), "FixedObjectFileStream temporary file destruction failed");
        }
Пример #2
0
        public void InitializeFixedObjectFileStreamTest()
        {
            Stream s = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(s);

            Assert.IsTrue(File.Exists(FixedObjectFileStream.TempStreamFile), "FixedObjectFileStream temporary file creation failed");
            instance.Dispose();
            Assert.IsFalse(File.Exists(FixedObjectFileStream.TempStreamFile), "FixedObjectFileStream temporary file destruction failed");
        }
Пример #3
0
        public void FixedObjectFileStreamAddTest()
        {
            var rcf  = RandomCharFunc();
            var rcfN = RandomCharFunc(true);
            var rdf  = RandomDayFunc();
            var rnf  = RandomNumberFunc(10, 100);

            int rnd = rnf();

            TruckInfo[] tis = new TruckInfo[rnd];
            for (int i = 0; i < tis.Length; i++)
            {
                TruckInfo ti = tis[i];
                ti                = new TruckInfo();
                ti.nrCrt          = RandomNumberFunc(0)();
                ti.nrAuto         = rcf().ToString() + rcf() + "-" + rcfN().ToString() + rcfN() + rcfN().ToString() + "-" + rcf().ToString() + rcf() + rcf().ToString();
                ti.payload        = "" + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString();
                ti.dateEntry      = rdf();
                ti.dateRegistered = rdf();
                tis[i]            = ti;
            }

            Stream ms = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(ms);

            instance.Add(tis);
            instance.FillTestStream(ms);

            ms.Seek(0, SeekOrigin.Begin);
            int count;

            byte[] b = new byte[4];
            ms.Read(b, 0, 4);
            count = BitConverter.ToInt32(b, 0);
            Assert.AreEqual(count, tis.Length);

            foreach (TruckInfo ti in tis)
            {
                TruckInfo result = new TruckInfo(ms);

                Assert.IsTrue(ti == result);
            }
        }
Пример #4
0
        public void FixedObjectFileStreamAddTest()
        {
            var rcf = RandomCharFunc();
            var rcfN = RandomCharFunc(true);
            var rdf = RandomDayFunc();
            var rnf = RandomNumberFunc(10, 100);

            int rnd = rnf();

            TruckInfo[] tis = new TruckInfo[rnd];
            for (int i = 0; i < tis.Length; i++) {
                TruckInfo ti = tis[i];
                ti = new TruckInfo();
                ti.nrCrt = RandomNumberFunc(0)();
                ti.nrAuto = rcf().ToString() + rcf() + "-" + rcfN().ToString() + rcfN() + rcfN().ToString() + "-" + rcf().ToString() + rcf() + rcf().ToString();
                ti.payload = "" + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString() + rcf() + rcf().ToString();
                ti.dateEntry = rdf();
                ti.dateRegistered = rdf();
                tis[i] = ti;
            }

            Stream ms = new MemoryStream();
            FixedObjectFileStream instance = new FixedObjectFileStream(ms);
            instance.Add(tis);
            instance.FillTestStream(ms);

            ms.Seek(0, SeekOrigin.Begin);
            int count;
            byte[] b = new byte[4];
            ms.Read(b, 0, 4);
            count = BitConverter.ToInt32(b, 0);
            Assert.AreEqual(count, tis.Length);

            foreach (TruckInfo ti in tis) {
                TruckInfo result = new TruckInfo(ms);

                Assert.IsTrue(ti == result);
            }
        }