public void ReturnsSaveData() { // Arrange var saveDataFiles = new[] { Resources.SaveData, Resources.SaveData_76561197960481221, Resources.SaveData_76561198074553183, Resources.SaveData_76561198252120446, }; foreach (var saveDataFile in saveDataFiles) { var readStream = new MemoryStream(Encoding.UTF8.GetBytes(saveDataFile)); var reader = new SaveDataReader(readStream); // Act var saveData = reader.Read(); // Assert var writeStream = new MemoryStream(); var writer = new SaveDataWriter(writeStream); writer.Write(saveData); writeStream.Position = 0; var sr = new StreamReader(writeStream); var actual = sr.ReadToEnd(); Assert.Equal(saveDataFile, actual, ignoreLineEndingDifferences: true); } }
public void SaveDataIsNull_ThrowsArgumentNullException() { // Arrange var stream = Stream.Null; var writer = new SaveDataWriter(stream); SaveData saveData = null; // Act -> Assert Assert.Throws <ArgumentNullException>(() => { writer.Write(saveData); }); }
/// <summary> /// /// </summary> /// <param name="stream"></param> /// <param name="saveData"></param> public void Serialize(Stream stream, SaveData saveData) { var writer = new SaveDataWriter(stream); writer.Write(saveData); }