public void Iterator_NullInput_Throws_ArgumentNullException() { var writer = new MifareCardWriter(); Assert.Throws <ArgumentNullException>(() => { writer.GenerateChunk(null).GetEnumerator().MoveNext(); }); }
public void Iterator_EmptyInput_NotGenerateOutput() { var writer = new MifareCardWriter(); foreach (var bytes in writer.GenerateChunk(EmptyData)) { Assert.Fail(); } Assert.Pass(); }
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)); }
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)); } }