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 DeserializeThrowsIfModeIsOutOfRange() { // Arrange MvcSerializer serializer = new MvcSerializer(); // Act & assert Assert.ThrowsArgumentOutOfRange( delegate { serializer.Serialize("blah", (SerializationMode)(-1)); }, "mode", @"The provided SerializationMode is invalid."); }
public void SerializeAllowsNullValues() { // Arrange MvcSerializer serializer = new MvcSerializer(); // Act string serializedValue = serializer.Serialize(null, SerializationMode.Plaintext); // Assert Assert.AreEqual(@"/wFk", serializedValue); }
public void SerializeThrowsIfModeIsOutOfRange() { // Arrange MvcSerializer serializer = new MvcSerializer(); // Act & assert Assert.ThrowsArgumentOutOfRange( delegate { serializer.Serialize(null, (SerializationMode)(-1)); }, "mode", @"The provided SerializationMode is invalid."); }
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 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 MvcSerializer serializer = new MvcSerializer(); // Act string serializedValue = serializer.Serialize(42, SerializationMode.Plaintext); object deserializedValue = serializer.Deserialize(serializedValue, SerializationMode.Plaintext); // Assert Assert.AreEqual(42, deserializedValue, "Value was not round-tripped properly."); }
public void SerializeThrowsIfModeIsOutOfRange() { // Arrange MvcSerializer serializer = new MvcSerializer(); // Act & assert ExceptionHelper.ExpectArgumentOutOfRangeException( delegate { serializer.Serialize(null, (SerializationMode)(-1)); }, "mode", @"The provided SerializationMode is invalid. Parameter name: mode"); }
public static string Serialize <T>(this T toSerialize) { var serializer = new MvcSerializer(); return(serializer.Serialize(toSerialize, MvcSerializer.DefaultSerializationMode)); }