[TestCase(PhraseCustomization.CustomizationType.InsertionBefore, "")] // FWIW: In real life, it can't be an empty string. public void Key_CustomizationBasedOnAddedQuestionWithExplicitKey_KeyBasedOnExplicitKey( PhraseCustomization.CustomizationType type, string questionInEnglish) { var explicitKey = Question.kGuidPrefix + Guid.NewGuid(); var pc = new PhraseCustomization($"Is this the {GetAdjectiveForBaseQuestion(type)} question?", new Question("TST 8:9", 100008009, 100008009, questionInEnglish, "Tal vez", explicitKey), type); Assert.AreEqual(explicitKey, pc.ImmutableKey); pc.ModifiedPhrase = "Changed it!"; Assert.AreEqual(explicitKey, pc.ImmutableKey); Assert.AreEqual(pc.ImmutableKey, pc.ImmutableKey_PublicForSerializationOnly); }
private static string GetAdjectiveForBaseQuestion(PhraseCustomization.CustomizationType type) => type == PhraseCustomization.CustomizationType.AdditionAfter ? "preceding" : "following";
public void Key_CustomizationBasedOnAddedQuestionWithoutEnglishVersion_KeyAssignedToNewGuidWithPrefix(PhraseCustomization.CustomizationType type) { var pc = new PhraseCustomization($"Is this the {GetAdjectiveForBaseQuestion(type)} question?", new Question("TST 8:9", 100008009, 100008009, null, "Tal vez"), type); Assert.IsTrue(pc.ImmutableKey.StartsWith(Question.kGuidPrefix)); Assert.IsTrue(Guid.TryParse(pc.ImmutableKey.Substring(Question.kGuidPrefix.Length), out _)); }
public void Key_CustomizationBasedOnAddedQuestionWithEnglishVersion_KeyBasedOnEnglishQuestion(PhraseCustomization.CustomizationType type) { var pc = new PhraseCustomization($"Is this the {GetAdjectiveForBaseQuestion(type)} question?", new Question("TST 8:9", 100008009, 100008009, "Is this a user-added question?", "Yes"), type); Assert.AreEqual("Is this a user-added question?", pc.ImmutableKey); Assert.IsNull(pc.ImmutableKey_PublicForSerializationOnly); }