public void MutationalChangeEmptyTest() { var value = new MutationalChange() { Append = null, AppendIterations = new FromToValue <ushort>(0), Description = "Empty", RemoveLength = new FromToValue <ushort>(1), Weight = 1 }; // With remove var result = value.Process(0); Assert.IsNotNull(result); Assert.AreEqual("Empty", result.Description); Assert.IsNull(result.Append); Assert.AreEqual(1, result.Remove); Assert.AreEqual(0, result.Offset); // Null value.RemoveLength = new FromToValue <ushort>(0); result = value.Process(0); Assert.IsNull(result); }
public void TestMutationalChange() { MutationalChange c = new MutationalChange() { AppendByte = new FromToValue <byte>((byte)'A'), RemoveLength = new FromToValue <ushort>(1), AppendLength = new FromToValue <ushort>(1), }; PatchChange ret = c.Process(0); ret = c.Process(0); ret = c.Process(0); }
public void MutationalChangeChunkTest() { var c = new MutationalChange() { Description = "Test", Append = new MutationalChunk(new byte[][] { new byte[] { 0x01, 0x02 }, new byte[] { 0x03, 0x04 } }), RemoveLength = new FromToValue <ushort>(0), AppendIterations = new FromToValue <ushort>(1), Weight = 1 }; var data = new List <string> { StringHelper.ByteArrayToHex(new byte[] { 0x01, 0x02 }), StringHelper.ByteArrayToHex(new byte[] { 0x03, 0x04 }) }; for (int x = 0; x < 100; x++) { var ret = c.Process(0); var hex = StringHelper.ByteArrayToHex(ret.Append); Assert.IsTrue(data.Contains(hex)); Assert.AreEqual(0, ret.Offset); Assert.AreEqual(0, ret.Remove); Assert.AreEqual(2, ret.Append.Length); Assert.AreEqual("Test", ret.Description); } }
public void MutationalChangeSingleByteTest() { var c = new MutationalChange() { Description = "Test", Append = new MutationalFromTo(1, 100), RemoveLength = new FromToValue <ushort>(4), AppendIterations = new FromToValue <ushort>(4), Weight = 1 }; var data = new List <string>(); for (int x = 0; x < 100; x++) { var ret = c.Process(0); var hex = StringHelper.ByteArrayToHex(ret.Append); Assert.IsFalse(data.Contains(hex)); data.Add(hex); Assert.AreEqual(0, ret.Offset); Assert.AreEqual(4, ret.Remove); Assert.AreEqual(4, ret.Append.Length); Assert.AreEqual("Test", ret.Description); Assert.IsTrue(ret.Append[0] >= 1 && ret.Append[0] <= 100); Assert.IsTrue(ret.Append[1] >= 1 && ret.Append[1] <= 100); Assert.IsTrue(ret.Append[2] >= 1 && ret.Append[2] <= 100); Assert.IsTrue(ret.Append[3] >= 1 && ret.Append[3] <= 100); } }