public void ReadItemTest() { var cases = new[] { new ItemTestCase() { Name = "a", Value = "b" }, new ItemTestCase() { Name = "X-DL", ParamList = "Design Work Group", Value = "List Item 1;List Item 2;List Item 3" }, new ItemTestCase() { Groups = "A0", Name = "ADR", ParamList = "DOM;HOME", Value = "P.O. Box 101;Suite 101; 123 Main Street" }, }; foreach (var @case in cases) { var itemLine = @case.ToString(); using (var sr = new StringReader(itemLine)) { var vr = new VCardReader(sr); vr.Read(); Assert.AreEqual(VCardReaderState.Item, vr.State, string.Format("Case [{0}], State not match.", @case)); Assert.AreEqual(@case.Groups, vr.Groups, string.Format("Case [{0}], Groups not match.", @case)); Assert.AreEqual(@case.Name, vr.Name, string.Format("Case [{0}], Name not match.", @case)); Assert.AreEqual(@case.ParamList, vr.Params, string.Format("Case [{0}], ParamList not match.", @case)); Assert.AreEqual(@case.Value, vr.Value, string.Format("Case [{0}], Value not match.", @case)); } } }
public void WriteACard() { var TestObject = new VCardWriter(); var ResultReader = new VCardReader(); using (var ResultFile = File.Open("./Results/WriteACard.vcf", FileMode.OpenOrCreate)) { Assert.True(TestObject.Write(ResultFile, new GenericCard { Addresses = new IAddress[] { new Address { Street = "111 Floyd Ave.", City = "NumberPlace", StateOrProvence = "ThatOne", ZipCode = "11122", Type = "home" } }.ToList(), DirectDial = new IPhoneNumber[] { new PhoneNumber { Number = "111-1111", Type = "Work" } }.ToList(), Email = new IMailAddress[] { new MailAddress { EmailAddress = "*****@*****.**", Type = "Work" } }.ToList(), FirstName = "FirstName", LastName = "LastName", MiddleName = "MiddleName", Organization = "OrgName", Prefix = "Prefix", Suffix = "Suffix", Title = "Title", Url = "http://www.somewhere.com" })); } using (var ResultFile = File.Open("./Results/WriteACard.vcf", FileMode.OpenOrCreate)) { var Result = ResultReader.Read(ResultFile); Assert.Contains(Result.DirectDial, x => x.Type == "WORK" && x.Number == "111-1111"); Assert.Contains(Result.Email, x => x.Type == "WORK" && x.EmailAddress == "*****@*****.**"); Assert.Contains(Result.Addresses, x => x.Type == "HOME" && x.Street == "111 Floyd Ave." && x.City == "NumberPlace" && x.StateOrProvence == "ThatOne" && x.ZipCode == "11122"); Assert.Equal("FirstName", Result.FirstName); Assert.Equal("Prefix FirstName MiddleName LastName Suffix", Result.FullName); Assert.Equal("LastName", Result.LastName); Assert.Equal("MiddleName", Result.MiddleName); Assert.Equal("OrgName", Result.Organization); Assert.Equal("Prefix", Result.Prefix); Assert.Equal(0, Result.Relationships.Count); Assert.Equal("Suffix", Result.Suffix); Assert.Equal("Title", Result.Title); Assert.Equal("http://www.somewhere.com", Result.Url); } }