public void SerializeAllowsNullValues() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act string serializedValue = MvcSerializer.Serialize(null, SerializationMode.EncryptedAndSigned, machineKey); // Assert Assert.AreEqual(@"All-LPgGI1dzEbp3B2FueVR5cGUuA25pbIYJAXozaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS8yMDAzLzEwL1NlcmlhbGl6YXRpb24vCQFpKWh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlAQ==", serializedValue); }
public void SerializeAllowsNullValues() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act string serializedValue = MvcSerializer.Serialize(null, machineKey); // Assert Assert.Equal(@"Microsoft.Web.Mvc.MvcSerializer.v1-dwdhbnlUeXBlLgNuaWyGCQF6M2h0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vMjAwMy8xMC9TZXJpYWxpemF0aW9uLwkBaSlodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZQE=", serializedValue); }
public void SerializeAndDeserializeRoundTripsValue() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act string serializedValue = MvcSerializer.Serialize(42, SerializationMode.EncryptedAndSigned, machineKey); object deserializedValue = MvcSerializer.Deserialize(serializedValue, SerializationMode.EncryptedAndSigned, machineKey); // Assert Assert.AreEqual(42, deserializedValue, "Value was not round-tripped properly."); }
public void SerializeAndDeserializeRoundTripsValue() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act string serializedValue = MvcSerializer.Serialize(42, machineKey); object deserializedValue = MvcSerializer.Deserialize(serializedValue, machineKey); // Assert Assert.Equal(42, deserializedValue); }
public void DeserializeThrowsIfSerializedValueIsCorrupt() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act & assert Exception exception = Assert.Throws <SerializationException>( delegate { MvcSerializer.Deserialize("This is a corrupted value.", machineKey); }, @"Deserialization failed. Verify that the data is being deserialized using the same SerializationMode with which it was serialized. Otherwise see the inner exception."); Assert.NotNull(exception.InnerException); }
public void DeserializeThrowsIfSerializedValueIsCorrupt() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act & assert Exception exception = Assert.Throws<SerializationException>( delegate { MvcSerializer.Deserialize("This is a corrupted value.", SerializationMode.Signed, machineKey); }, @"Deserialization failed. Verify that the data is being deserialized using the same SerializationMode with which it was serialized. Otherwise see the inner exception."); Assert.NotNull(exception.InnerException); }
public void DeserializeThrowsIfSerializedValueIsCorrupt() { // Arrange IMachineKey machineKey = new MockMachineKey(); // Act & assert Exception exception = ExceptionHelper.ExpectException <SerializationException>( delegate { MvcSerializer.Deserialize("This is a corrupted value.", SerializationMode.Signed, machineKey); }, @"Deserialization failed. Verify that the data is being deserialized using the same SerializationMode with which it was serialized. Otherwise see the inner exception."); Assert.IsNotNull(exception.InnerException, "Inner exception was not propagated correctly."); }