using Tessera.Text; using UnitTestSharp; namespace Tessera.UnitTests.Text { public class PronounHoleTests : TestFixture { public class PackAndUnpackTests : TestFixture { public void WithNothingToAgreeWith_IsTheReferentAlone() { CheckEqual((long)Referent.They, PronounHole.Pack(Referent.They, default)); } public void WithNothingToAgreeWith_ComesBackAsNothing() { Agreement agreement = PronounHole.Unpack(PronounHole.Pack(Referent.Female, default), out Referent who); CheckEqual(Referent.Female, who); CheckFalse(agreement.IsGiven); } public void EveryTrait_ComesBack() { var given = new Agreement(gender: 255, isPlural: true, GrammarRole.Genitive); Agreement agreement = PronounHole.Unpack(PronounHole.Pack(Referent.They, given), out Referent who); CheckEqual(Referent.They, who); CheckTrue(agreement.IsGiven); CheckEqual(255, agreement.Gender); CheckTrue(agreement.IsPlural); CheckEqual(GrammarRole.Genitive, agreement.Role); } public void TheFirstGenderAndRole_ComeBackAsGiven() { var given = new Agreement(gender: 0, isPlural: false, GrammarRole.Subject); Agreement agreement = PronounHole.Unpack(PronounHole.Pack(Referent.Male, given), out Referent who); CheckEqual(Referent.Male, who); CheckTrue(agreement.IsGiven); CheckEqual(0, agreement.Gender); CheckFalse(agreement.IsPlural); CheckEqual(GrammarRole.Subject, agreement.Role); } public void EachTraitStaysOutOfTheOthers() { var given = new Agreement(gender: 255, isPlural: false, GrammarRole.Subject); Agreement agreement = PronounHole.Unpack(PronounHole.Pack(Referent.Male, given), out Referent who); CheckEqual(Referent.Male, who); CheckEqual(255, agreement.Gender); CheckFalse(agreement.IsPlural); CheckEqual(GrammarRole.Subject, agreement.Role); } public void EveryReferentAndRole_ComeBack() { for (int referent = 0; referent < GrammarRules.ReferentCount; ++referent) { for (int role = 0; role < GrammarRules.NounRoleCount; ++role) { var given = new Agreement(gender: 1, isPlural: true, (GrammarRole)role); Agreement agreement = PronounHole.Unpack(PronounHole.Pack((Referent)referent, given), out Referent who); CheckEqual((Referent)referent, who); CheckEqual((GrammarRole)role, agreement.Role); } } } } } }