public void SaveDataIsNull_ThrowsArgumentNullException() { // Arrange var serializer = new SaveDataSerializer(); var stream = Stream.Null; SaveData saveData = null; // Act -> Assert Assert.Throws <ArgumentNullException>(() => { serializer.Serialize(stream, saveData); }); }
public void SerializesSaveData() { // Arrange var serializer = new SaveDataSerializer(); var writeStream = new MemoryStream(); var readStream = new MemoryStream(Encoding.UTF8.GetBytes(Resources.SaveData)); var saveData = serializer.Deserialize(readStream); // Act serializer.Serialize(writeStream, saveData); // Assert writeStream.Position = 0; var sr = new StreamReader(writeStream); var actual = sr.ReadToEnd(); Assert.Equal(Resources.SaveData, actual, ignoreLineEndingDifferences: true); }