public void Shoud_not_detect_gender_if_auto_detection_is_not_set(string middleName) { var petrovich = new Petrovich { AutoDetectGender = false, MiddleName = middleName }; petrovich.InflectMiddleNameTo(Case.Accusative); Assert.AreEqual(Gender.Androgynous, petrovich.Gender); }
public void Shoud_detect_gender_if_auto_detection_is_set(string middleName, Gender expected) { var petrovich = new Petrovich {AutoDetectGender = true, MiddleName = middleName}; petrovich.InflectMiddleNameTo(Case.Accusative); Assert.AreEqual(expected, petrovich.Gender); }
public void Should_return_full_name_if_cast_to_string() { var petrovich = new Petrovich { FirstName = "Петр", LastName = "Петров", MiddleName = "Петрович" }; Assert.AreEqual("Петров Петр Петрович", petrovich.ToString()); }
public void Shoud_detect_gender_if_auto_detection_is_set(string middleName, Gender expected) { var petrovich = new Petrovich { AutoDetectGender = true, MiddleName = middleName }; petrovich.InflectMiddleNameTo(Case.Accusative); Assert.AreEqual(expected, petrovich.Gender); }
private static bool EvaluateCase(EvaluateParameters parameters, IEvalCase @case, out string inflectResult) { var petrovich = new Petrovich { Gender = @case.Gender }; parameters.PetrovichAccessor(petrovich, @case.Lemma); inflectResult = parameters.PetrovichInflectAccessor(petrovich, @case.Case); var isActive = inflectResult.ToLower().Equals(@case.Word.ToLower()); return isActive; }
private static bool EvaluateCase(EvaluateParameters parameters, IEvalCase @case, out string inflectResult) { var petrovich = new Petrovich { Gender = @case.Gender }; parameters.PetrovichAccessor(petrovich, @case.Lemma); inflectResult = parameters.PetrovichInflectAccessor(petrovich, @case.Case); var isActive = inflectResult.ToLower().Equals(@case.Word.ToLower()); return(isActive); }
static void Main(string[] args) { //NPetrovichLite.Tests.TestDataFactory.ReadSurnamesData().OfType<object[]>().ToList(); //Petrovich petrovich = new Petrovich(@"..\..\..\rules\rules.json", @"..\..\..\rules\gender.json"); /* * Petrovich petrovich = new Petrovich(); * Console.WriteLine(petrovich.Inflect("Маша", NamePart.FirstName, Case.Dative)); * Console.WriteLine(petrovich.Inflect("Паша", NamePart.FirstName, Case.Dative)); * Console.WriteLine(petrovich.Inflect("Саша", NamePart.FirstName, Case.Dative, Gender.Female)); */ /* * Petrovich petrovich = new Petrovich(); * Petrovich.FIO a = petrovich.Inflect(new Petrovich.FIO() { lastName = "Пушкин", firstName = "Александр", midName = "Сергеевич" }, Case.Dative); * Console.WriteLine(a); * Petrovich.FIO b = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей" }, Case.Dative, Gender.Female); * Console.WriteLine(b); * Petrovich.FIO c = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }, Case.Dative); * Console.WriteLine(c); */ /* * Petrovich petrovich = new Petrovich(); * Console.WriteLine(petrovich.GetGender("Пушкин", NamePart.LastName)); * Console.WriteLine(petrovich.GetGender("Пушкин", null, "Сергеевич")); * Console.WriteLine(petrovich.GetGender(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" })); */ /* * InflectSinglePart testFixture = new InflectSinglePart(); * testFixture.Init(); * MethodInfo mi = testFixture.GetType().GetMethod(nameof(InflectSinglePart.TestSinglePartInflection)); * foreach (object[] par in TestDataFactory.ReadSurnamesData()) * { * mi.Invoke(testFixture, par); * } */ Petrovich petrovich = new Petrovich(); Console.WriteLine(petrovich.Inflect("Aгриппа", NamePart.LastName, Case.Genitive)); Console.WriteLine(petrovich.Inflect("Кваша", NamePart.LastName, Case.Genitive)); }
static void Main(string[] args) { //NPetrovichLite.Tests.TestDataFactory.ReadSurnamesData().OfType<object[]>().ToList(); //Petrovich petrovich = new Petrovich(@"c:\Dev\_Projects\petrovich-net\src\rules\rules.json"); /* Petrovich petrovich = new Petrovich(); Console.WriteLine(petrovich.Inflect("Маша", NamePart.FirstName, Case.Dative)); Console.WriteLine(petrovich.Inflect("Паша", NamePart.FirstName, Case.Dative)); Console.WriteLine(petrovich.Inflect("Саша", NamePart.FirstName, Case.Dative, Gender.Female)); */ /* Petrovich petrovich = new Petrovich(); Petrovich.FIO a = petrovich.Inflect(new Petrovich.FIO() { lastName = "Пушкин", firstName = "Александр", midName = "Сергеевич" }, Case.Dative); Console.WriteLine(a); Petrovich.FIO b = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей" }, Case.Dative, Gender.Female); Console.WriteLine(b); Petrovich.FIO c = petrovich.Inflect(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" }, Case.Dative); Console.WriteLine(c); */ /* Petrovich petrovich = new Petrovich(); Console.WriteLine(petrovich.GetGender("Пушкин", NamePart.LastName)); Console.WriteLine(petrovich.GetGender("Пушкин", null, "Сергеевич")); Console.WriteLine(petrovich.GetGender(new Petrovich.FIO() { lastName = "Воробей", firstName = "Александр" })); */ /* InflectSinglePart testFixture = new InflectSinglePart(); testFixture.Init(); MethodInfo mi = testFixture.GetType().GetMethod(nameof(InflectSinglePart.TestSinglePartInflection)); foreach (object[] par in TestDataFactory.ReadSurnamesData()) { mi.Invoke(testFixture, par); } */ Petrovich petrovich = new Petrovich(); //Console.WriteLine(petrovich.Inflect("Aгриппа", NamePart.LastName, Case.Genitive)); Console.WriteLine(petrovich.Inflect("Кваша", NamePart.LastName, Case.Genitive)); }
public void Init() { petrovich = new Petrovich(); }
public void Should_throw_ArgumentNullException_if_any_name_is_not_provided(string firstName, string lastName, string middleName) { var petrovich = new Petrovich(); Assert.Throws <ArgumentNullException>(() => petrovich.InflectTo(Case.Accusative)); }
public void Should_throw_ArgumentNullException_if_middle_name_is_not_provided() { var petrovich = new Petrovich(); Assert.Throws <ArgumentNullException>(() => petrovich.InflectMiddleNameTo(Case.Accusative)); }
public void Should_return_full_name_if_cast_to_string() { var petrovich = new Petrovich {FirstName = "Петр", LastName = "Петров", MiddleName = "Петрович"}; Assert.AreEqual("Петров Петр Петрович", petrovich.ToString()); }
public void Should_throw_ArgumentNullException_if_any_name_is_not_provided(string firstName, string lastName, string middleName) { var petrovich = new Petrovich(); Assert.Throws<ArgumentNullException>(() => petrovich.InflectTo(Case.Accusative)); }
public void Should_throw_ArgumentNullException_if_middle_name_is_not_provided() { var petrovich = new Petrovich(); Assert.Throws<ArgumentNullException>(() => petrovich.InflectMiddleNameTo(Case.Accusative)); }