コード例 #1
0
        public void Iterator_NullInput_Throws_ArgumentNullException()
        {
            var writer = new MifareCardWriter();

            Assert.Throws <ArgumentNullException>(() =>
            {
                writer.GenerateChunk(null).GetEnumerator().MoveNext();
            });
        }
コード例 #2
0
        public void Iterator_EmptyInput_NotGenerateOutput()
        {
            var writer = new MifareCardWriter();

            foreach (var bytes in writer.GenerateChunk(EmptyData))
            {
                Assert.Fail();
            }
            Assert.Pass();
        }
コード例 #3
0
        public void Iterator_InputBytesEquivalentToOutput(byte[] testData)
        {
            var writer      = new MifareCardWriter();
            var resultBytes = new List <byte>();

            foreach (var bytes in writer.GenerateChunk(testData))
            {
                Console.WriteLine(BitConverter.ToString(bytes));
                resultBytes.AddRange(bytes);
            }

            Assert.That(testData, Is.EquivalentTo(resultBytes));
        }
コード例 #4
0
        public void Iterator_InputBytesBreaksIntoGroupsOfBlockSize(byte[] testData)
        {
            var writer        = new MifareCardWriter();
            var bytesPerBlock = MifareCardWriter.BytesPerBlock;
            var resultBytes   = new List <byte[]>();

            foreach (var bytes in writer.GenerateChunk(testData))
            {
                Console.WriteLine(BitConverter.ToString(bytes));
                resultBytes.Add(bytes);
            }

            foreach (var bytes in resultBytes.Take(resultBytes.Count - 1))
            {
                Assert.AreEqual(bytesPerBlock, bytes.Length);
            }

            if (resultBytes.Count != 0)
            {
                var lastChunk = resultBytes.Last().ToArray();
                Assert.That(lastChunk.Length, Is.InRange(0, bytesPerBlock));
            }
        }