public void WritePhoneContact() { string exceptionMes = string.Empty; Contact phoneContact = new PhoneContact(); Contact standard = new PhoneContact("Yuriy", "5432167890"); StreamWriter streamWriter = new StreamWriter("../../PhoneContactOutput.txt"); try { standard.Write(streamWriter); streamWriter.Close(); streamWriter.Dispose(); StreamReader streamReader = new StreamReader("../../PhoneContactOutput.txt"); phoneContact.Read(streamReader); streamReader.Close(); streamReader.Dispose(); } catch (ArgumentException mes) { exceptionMes = mes.Message; } Assert.AreEqual(phoneContact.Name, standard.Name); Assert.AreEqual(phoneContact.Data, standard.Data); Assert.AreEqual(exceptionMes, string.Empty); }
public void ReadPhoneContact() { string exceptionMes = string.Empty; Contact phoneContact = new PhoneContact(); Contact standard = new PhoneContact("Zakalic", "1029384756"); StreamReader stream = new StreamReader("../../PhoneContactInput.txt"); try { phoneContact.Read(stream); stream.Close(); stream.Dispose(); } catch (ArgumentException mes) { exceptionMes = mes.Message; } Assert.AreEqual(phoneContact.Name, standard.Name); Assert.AreEqual(phoneContact.Data, standard.Data); Assert.AreEqual(exceptionMes, string.Empty); }