public void CSBadDeserializeGroupElementArrayTest() { GroupElement[] input = StaticHelperClass.GenerateRandomBases(10, paramIndex); string[] serialized = CryptoSerializer.SerializeGroupElementArray(input, 3, 4, "blah"); Assert.AreEqual(4, serialized.Length, "serialized array length"); StaticHelperClass.TryBodyDelegate negativeStartIndex = new StaticHelperClass.TryBodyDelegate( () => { GroupElement[] output = CryptoSerializer.DeserializeGroupElementArray(serialized, -1, 10, "blah", crypto.Group); }); StaticHelperClass.AssertThrowsException(negativeStartIndex, typeof(Exception), "negative start index"); StaticHelperClass.TryBodyDelegate startIndexTooLarge = new StaticHelperClass.TryBodyDelegate( () => { GroupElement[] output = CryptoSerializer.DeserializeGroupElementArray(serialized, 8, 10, "blah", crypto.Group); }); StaticHelperClass.AssertThrowsException(startIndexTooLarge, typeof(Exception), "start index too large"); StaticHelperClass.TryBodyDelegate startIndexWaytooLarge = new StaticHelperClass.TryBodyDelegate( () => { GroupElement[] output = CryptoSerializer.DeserializeGroupElementArray(serialized, 11, 10, "blah", crypto.Group); }); StaticHelperClass.AssertThrowsException(startIndexWaytooLarge, typeof(Exception), "start index greater than output length "); }
public void CSGroupElementArrayTest() { GroupElement[] input = StaticHelperClass.GenerateRandomBases(10, paramIndex); string[] output = CryptoSerializer.SerializeGroupElementArray(input, "blah"); Assert.AreEqual(input.Length, output.Length, "serialized array length different."); GroupElement[] deserialized = CryptoSerializer.DeserializeGroupElementArray(output, "blah", crypto.Group); StaticHelperClass.AssertArraysAreEqual(input, deserialized, "deserialized"); }
public void CSGroupElementArrayTest2() { GroupElement[] input = StaticHelperClass.GenerateRandomBases(10, paramIndex); string[] serialized = CryptoSerializer.SerializeGroupElementArray(input, 3, 4, "blah"); Assert.AreEqual(4, serialized.Length, "serialized array length"); GroupElement[] output = CryptoSerializer.DeserializeGroupElementArray(serialized, 3, 10, "output", crypto.Group); GroupElement [] expectedOutput = new GroupElement[10] { null, null, null, input[3], input[4], input[5], input[6], null, null, null }; StaticHelperClass.AssertArraysAreEqual(expectedOutput, output, "output"); GroupElement[] output2 = CryptoSerializer.DeserializeGroupElementArray(serialized, 0, 10, "output2", crypto.Group); GroupElement[] expectedOutput2 = new GroupElement[10] { input[3], input[4], input[5], input[6], null, null, null, null, null, null }; StaticHelperClass.AssertArraysAreEqual(expectedOutput2, output2, "output2"); GroupElement[] output3 = CryptoSerializer.DeserializeGroupElementArray(serialized, 6, 10, "output3", crypto.Group); GroupElement[] expectedOutput3 = new GroupElement[10] { null, null, null, null, null, null, input[3], input[4], input[5], input[6] }; StaticHelperClass.AssertArraysAreEqual(expectedOutput3, output3, "output3"); }