コード例 #1
0
        public void UkrainianDeclension()
        {
            var webClient = new Mock <IWebClient>();

            webClient.Setup(client => client.QueryString).Returns(new NameValueCollection());
            webClient.Setup(client => client.DownloadString(It.IsAny <string>())).Returns(DeclensionResultText);
            var morpherClient = new MorpherClient(null, null, webClient.Object);

            var declension = new Declension(morpherClient.Ukrainian);

            IParse parsedResult = declension.Parse("помідор");

            Assert.IsNotNull(parsedResult);
            Assert.AreEqual("помідор", parsedResult.Nominative);
            Assert.AreEqual("помідора", parsedResult.Genitive);
            Assert.AreEqual("помідору", parsedResult.Dative);
            Assert.AreEqual("помідора", parsedResult.Accusative);
            Assert.AreEqual("помідором", parsedResult.Instrumental);
            Assert.AreEqual("помідорі", parsedResult.Prepositional);
            Assert.AreEqual("помідоре", parsedResult.Vocative);
            Assert.IsNull(parsedResult.Gender);

            webClient.Verify(client => client.QueryString, Times.AtLeastOnce());
            webClient.Verify(client => client.DownloadString(It.IsAny <string>()), Times.Once());
        }
コード例 #2
0
        public void RussianDeclension()
        {
            var webClient = new Mock <IWebClient>();

            webClient.Setup(client => client.QueryString).Returns(new NameValueCollection());
            webClient.Setup(client => client.DownloadString(It.IsAny <string>())).Returns(DeclensionResultText);
            var morpherClient = new MorpherClient(null, null, webClient.Object);

            var declension = new Declension(morpherClient.Russian);

            IParse parsedResult = declension.Parse("помидор");

            Assert.IsNotNull(parsedResult);
            Assert.AreEqual("помидор", parsedResult.Nominative);
            Assert.AreEqual("помидора", parsedResult.Genitive);
            Assert.AreEqual("помидору", parsedResult.Dative);
            Assert.AreEqual("помидор", parsedResult.Accusative);
            Assert.AreEqual("помидором", parsedResult.Instrumental);
            Assert.AreEqual("помидоре", parsedResult.Prepositional);
            Assert.IsNull(parsedResult.Locative);

            Assert.AreEqual("помидоры", parsedResult.Plural.Nominative);
            Assert.AreEqual("помидоров", parsedResult.Plural.Genitive);
            Assert.AreEqual("помидорам", parsedResult.Plural.Dative);
            Assert.AreEqual("помидоры", parsedResult.Plural.Accusative);
            Assert.AreEqual("помидорами", parsedResult.Plural.Instrumental);
            Assert.AreEqual("помидорах", parsedResult.Plural.Prepositional);

            Assert.IsNull(parsedResult.Gender);

            Assert.Throws <NotImplementedException>(() => { var fail = parsedResult.IsAnimate; });
            Assert.Throws <NotImplementedException>(() => { var fail = parsedResult.Paucal; });

            webClient.Verify(client => client.QueryString, Times.AtLeastOnce());
            webClient.Verify(client => client.DownloadString(It.IsAny <string>()), Times.Once());
        }