public void testJsonSerializingSentimentPhrases() { String expectedResult = "{" + "\"added\":[" + "{" + "\"title\":\"Feature: Cloud service\"," + "\"weight\":0" + "}" + "]," + "\"removed\":[\"Features\"]" + "}"; ISerializer serializer = new JsonSerializer(); IUpdateProxy<SentimentPhrase> proxy = Session.CreateSession("", "", serializer).CreateSentimentPhrasesUpdateProxy(); SentimentPhrase addedPhrase = new SentimentPhrase(); addedPhrase.Title = "Feature: Cloud service"; addedPhrase.Weight = 0.0f; proxy.Add(addedPhrase); SentimentPhrase removedPhrase = new SentimentPhrase(); removedPhrase.Title = "Features"; proxy.Remove(removedPhrase); SentimentPhraseManagable cm = (SentimentPhraseManagable)proxy.Stub; Regex rgx = new Regex("\\s{2,}"); Assert.AreEqual(expectedResult, rgx.Replace(serializer.Serialize(cm), "")); }
public void testXmlSerializingSentimentPhrases() { String expectedResult = "<?xml version=\"1.0\"?>" + "<phrases xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + "<added>" + "<phrase>" + "<title>name 1</title>" + "<weight>0.3</weight>" + "</phrase>" + "</added>" + "<removed>" + "<phrase>name 2</phrase>" + "</removed>" + "</phrases>"; ISerializer serializer = new XmlSerializer(); IUpdateProxy<SentimentPhrase> proxy = Session.CreateSession("", "", serializer).CreateSentimentPhrasesUpdateProxy(); SentimentPhrase addedPhrase = new SentimentPhrase(); addedPhrase.Title = "name 1"; addedPhrase.Weight = 0.3f; proxy.Add(addedPhrase); SentimentPhrase removedPhrase = new SentimentPhrase(); removedPhrase.Title = "name 2"; proxy.Remove(removedPhrase); SentimentPhraseManagable cm = (SentimentPhraseManagable)proxy.Stub; Regex rgx = new Regex("\\s{2,}"); Assert.AreEqual(expectedResult, rgx.Replace(serializer.Serialize(cm), "")); }