public void ClientSettingsFileSerializer_RoundTrip_FromFile() { // Arrange var guid = Guid.NewGuid(); var toFile = new List <ClientSettings> { new ClientSettings { ClientType = ClientType.FahClient, Name = "Foo", Server = "Bar", Port = 12345, Password = "******", Guid = guid } }; var serializer = new ClientSettingsFileSerializer(null); using (var artifacts = new ArtifactFolder()) { string path = artifacts.GetRandomFilePath(); // Act serializer.Serialize(path, toFile); var fromFile = serializer.Deserialize(path); // Assert Assert.AreEqual(toFile.Count, fromFile.Count); var to = toFile.First(); var from = fromFile.First(); Assert.AreEqual(to.ClientType, from.ClientType); Assert.AreEqual(to.Name, from.Name); Assert.AreEqual(to.Server, from.Server); Assert.AreEqual(to.Port, from.Port); Assert.AreEqual(to.Password, from.Password); Assert.AreEqual(to.Guid, from.Guid); } }
public void ClientSettingsFileSerializer_Serialize_GeneratesGuidValuesWhenGuidIsEmpty() { // Arrange var toFile = new List <ClientSettings> { new ClientSettings() }; var serializer = new ClientSettingsFileSerializer(null); using (var artifacts = new ArtifactFolder()) { string path = artifacts.GetRandomFilePath(); // Act serializer.Serialize(path, toFile); var fromFile = serializer.Deserialize(path); // Assert var from = fromFile.First(); Assert.AreNotEqual(Guid.Empty, from.Guid); } }