예제 #1
0
        public void CompareToMailTest()
        {
            var newMail = new Mail("1", "1");
            var newNewMail = new Mail("2", "2");
            var newNewNewMail = new Mail("1", "2");

            Assert.AreEqual(newNewMail.CompareTo(newMail), 1, "Mail.CompareTo broke");
            Assert.AreEqual(newMail.CompareTo(newNewMail), -1, "Mail.CompareTo broke");
            Assert.AreEqual(newMail.CompareTo(newMail), 0, "Mail.CompareTo broke");
            Assert.AreEqual(newMail.CompareTo(newNewNewMail), -1, "Mail.CompareTo broke");
            Assert.AreEqual(newNewNewMail.CompareTo(newMail), 1, "Mail.CompareTo broke");
        }
예제 #2
0
        private static void workingWithXml()
        {
            var contact1 = new Phone("1234", "4321");
            var contact2 = new Mail("dada", "netnet");

            var card1 = new Card(123,345,"cardName");
            card1.addMail("dada", "netnet");
            card1.addPhone("1234", "4321");

            Console.WriteLine(card1.ToXml());
        }
예제 #3
0
        private static void workingWithFile()
        {
            var contact1 = new Phone("1234", "4321");
            var contact2 = new Mail("dada","netnet");
            var contact3 = new Phone("5678","8765");

            var newList=new List<Contact>();
            newList.Add(contact1);
            newList.Add(contact2);
            newList.Add(contact3);

            var path = "D:\\Repositories\\CSharp\\HomeWork_5\\HomeWork_5\\contacts.txt";
            var sw=new StreamWriter(path);
            try
            {
                sw.WriteLine(newList[0].ToString());
                sw.WriteLine(newList[1].ToString());
                sw.WriteLine(newList[2].ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            finally
            {
                sw.Dispose();
            }
        }
예제 #4
0
 public void MyTestInitialize()
 {
     _card=new Card(123,123,"Name");
     _mail=new Mail("abc","def");
     _phone=new Phone("123","456");
 }