A game about forced loneliness, made by TACStudios
1using System.Linq;
2using NUnit.Framework;
3using Unity.Multiplayer.Center.Recommendations;
4
5namespace Unity.MultiplayerCenterTests
6{
7 /// <summary>
8 /// Cheap checks on some user visible text.
9 /// </summary>
10 [TestFixture]
11 internal class UserVisibleTextTests
12 {
13 static readonly string[] k_Verbs = {"is", "offers", "can", "costs", "would", "should", "works", "tends", "enables"};
14
15 [Test]
16 public void AllScoreImpacts_ShouldHaveANonEmptyReason()
17 {
18 var questionnaireData = UtilsForRecommendationTests.GetProjectQuestionnaire();
19 foreach (var question in questionnaireData.Questions)
20 {
21 foreach (var answer in question.Choices)
22 {
23 for (var index = 0; index < answer.ScoreImpacts.Length; index++)
24 {
25 var scoreImpact = answer.ScoreImpacts[index];
26 Assert.False(string.IsNullOrEmpty(scoreImpact.Comment),
27 $"Comment is empty for question {question.Id} answer {answer.Id} impact at index {index}");
28 }
29 }
30 }
31 }
32
33 [Test]
34 public void AllScoreImpacts_StartWithAVerbAndDoNotEndWithADot()
35 {
36 var questionnaireData = UtilsForRecommendationTests.GetProjectQuestionnaire();
37 foreach (var question in questionnaireData.Questions)
38 {
39 foreach (var answer in question.Choices)
40 {
41 for (var index = 0; index < answer.ScoreImpacts.Length; index++)
42 {
43 var comment = answer.ScoreImpacts[index].Comment;
44 var firstWord = comment.Split(' ')[0];
45 CollectionAssert.Contains(k_Verbs, firstWord,
46 $"Comment '{comment}' does not start with a verb for question {question.Id} answer {answer.Id} impact at index {index}");
47 Assert.False(comment.EndsWith("."),
48 $"Comment '{comment}' should not end with a dot for question {question.Id} answer {answer.Id} impact at index {index}");
49 }
50 }
51 }
52 }
53
54 [Test]
55 public void AllSolutionsData_DoNotHaveAVerbBeforeDynamicText()
56 {
57 var data = RecommenderSystemDataObject.instance.RecommenderSystemData;
58 const string dynamicKeyword = Scoring.DynamicKeyword;
59 foreach (var solution in data.RecommendedSolutions)
60 {
61 Assert.True(solution.ShortDescription.Contains(dynamicKeyword),
62 $"Solution {solution.Type} description does not contain dynamic text '{dynamicKeyword}'");
63 var wordBeforeDynamic = solution.ShortDescription.Split(dynamicKeyword)[0].Split(' ').Last();
64 Assert.False(k_Verbs.Contains(wordBeforeDynamic),
65 $"Solution {solution.Type} description starts with a verb '{wordBeforeDynamic}' before dynamic text '{dynamicKeyword}'");
66 }
67 }
68
69 }
70}