public void VCardTest() { storage.RemoveUser(username); var vcard1 = new Vcard { Fullname = username }; storage.SetVCard(username, vcard1); var vcard2 = storage.GetVCard(username); Assert.IsNull(vcard2); var u = new XmppUser(username, "password"); storage.SaveUser(u); vcard2 = storage.GetVCard(username); Assert.IsNull(vcard2); storage.SetVCard(username, vcard1); vcard2 = storage.GetVCard(username); Assert.AreEqual(vcard1.ToString(), vcard2.ToString()); vcard2 = storage.GetVCard("sss"); Assert.IsNull(vcard2); storage.SetVCard(username, null); vcard2 = storage.GetVCard(username); Assert.IsNull(vcard2); storage.RemoveUser(username); }
public override void ExecuteResult(ControllerContext context) { var response = context.HttpContext.Response; response.ContentType = "text/vcard"; response.AddHeader("Content-Disposition", "attachment; fileName=" + _card.FirstName + " " + _card.LastName + ".vcf"); var cardString = _card.ToString(); var inputEncoding = Encoding.Default; var outputEncoding = Encoding.GetEncoding("windows-1257"); var cardBytes = inputEncoding.GetBytes(cardString); var outputBytes = Encoding.Convert(inputEncoding, outputEncoding, cardBytes); response.OutputStream.Write(outputBytes, 0, outputBytes.Length); }