public void SerializationUtility_SaveToString_2() { CanaryClass first = new CanaryClass(); string text = first.SaveToString(); CanaryClass second = text.RestoreObjectFromString <CanaryClass>(); first.EnsureSame(second); }
public void SerializationUtility_SaveToZipMemory_1() { CanaryClass first = _GetCanary(); byte[] memory = first.SaveToZipMemory(); CanaryClass second = memory.RestoreObjectFromZipMemory <CanaryClass>(); first.EnsureSame(second); }
public void SerializationUtility_SaveToFile_1() { string fileName = Path.GetTempFileName(); CanaryClass first = _GetCanary(); first.SaveToFile(fileName); CanaryClass second = SerializationUtility.RestoreObjectFromFile <CanaryClass>(fileName); first.EnsureSame(second); }
public void SerializationUtility_RestoreNullable_1() { // ReSharper disable InvokeAsExtensionMethod CanaryClass first = _GetCanary(); MemoryStream stream = new MemoryStream(); BinaryWriter writer = new BinaryWriter(stream); SerializationUtility.WriteNullable(writer, first); byte[] bytes = stream.ToArray(); stream = new MemoryStream(bytes); BinaryReader reader = new BinaryReader(stream); CanaryClass second = SerializationUtility.RestoreNullable <CanaryClass>(reader); Assert.IsNotNull(second); first.EnsureSame(second); // ReSharper restore InvokeAsExtensionMethod }