public void ToString_NamespaceFollowedByKey()
        {
            const string expectedNamespace = "TestNameSpace";
            const string expectedKey       = "TestKey";

            var localisationKey = new LocalisationKey(expectedNamespace, expectedKey);

            Assert.IsTrue(localisationKey.ToString().Equals(expectedNamespace + ", " + expectedKey));
        }
        public void GetHashCode_NamespaceMultipliedByKeySquared()
        {
            const string expectedNamespace = "TestNameSpace";
            const string expectedKey       = "TestKey";

            var localisationKey = new LocalisationKey(expectedNamespace, expectedKey);

            Assert.AreEqual(expectedNamespace.GetHashCode() * expectedKey.GetHashCode() * expectedKey.GetHashCode(), localisationKey.GetHashCode());
        }
        public void Equals_MatchingKeyAndNamespace_True()
        {
            const string expectedNamespace = "TestNameSpace";
            const string expectedKey       = "TestKey";

            var localisationKey      = new LocalisationKey(expectedNamespace, expectedKey);
            var otherLocalisationKey = new LocalisationKey(expectedNamespace, expectedKey);

            Assert.IsTrue(otherLocalisationKey.Equals(localisationKey));
        }
        public void Equals_NotMatchingKeyButMatchingNamespace_False()
        {
            const string expectedNamespace = "TestNameSpace";
            const string expectedKey       = "TestKey";

            var localisationKey      = new LocalisationKey(expectedNamespace, expectedKey);
            var otherLocalisationKey = new LocalisationKey(expectedNamespace, "CRAAAAP");

            Assert.IsFalse(otherLocalisationKey.Equals(localisationKey));
        }
        public void Created_UsesNamespaceAndKeyProvided()
        {
            const string expectedNamespace = "TestNameSpace";
            const string expectedKey       = "TestKey";

            var localisationKey = new LocalisationKey(expectedNamespace, expectedKey);

            Assert.IsTrue(localisationKey.LocalisationNamespace.Equals(expectedNamespace));
            Assert.IsTrue(localisationKey.LocalisationKeyValue.Equals(expectedKey));
        }
        public void LocalisationComponent_GetTextForLocalisationKey_NotExisting_ThrowsErrorAndReturnsDefaultEntry()
        {
            _localisationComponent.TestAwake();

            var errornousKey = new LocalisationKey("OH NO ERROR", "BAD KEY BADDDDD");

            LogAssert.Expect(LogType.Error, "Could not find key " + errornousKey + "! Adding to loctext file");

            var generatedText = _localisationComponent.GetTextForLocalisationKey(errornousKey);

            foreach (var textEntries in generatedText.LocalisedTexts)
            {
                Assert.IsTrue(LocalisedTextConstants.DefaultLocalisedTextEntry.Equals(textEntries.Value));
            }
        }
Example #7
0
        public void GetTextFromLocalisationKey_QueriesLocalisationManagerToGetLocalisedText()
        {
            var locInterface = new MockLocalisationInterface();

            LocalisationManager.CurrentLocalisationInterface = locInterface;

            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.EnglishUK, "TEST")
            };

            locInterface.GetTextForLocalisationKeyResult = new LocalisedText(new LocalisedTextEntries(entries));

            var expectedKey = new LocalisationKey("Testy", "Test");

            Assert.AreEqual(locInterface.GetTextForLocalisationKeyResult.ToString(), LocalisedTextFunctions.GetTextFromLocalisationKey(expectedKey));
            Assert.AreSame(locInterface.SubmittedGetTextLocalisationKey, expectedKey);

            LocalisationManager.CurrentLocalisationInterface = null;
        }
Example #8
0
        public void LocalisedTextRef_ToString_UsesUnderlyingLocalisedText()
        {
            var locInterface = new MockLocalisationInterface();

            LocalisationManager.CurrentLocalisationInterface = locInterface;

            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.EnglishUK, "TEST")
            };

            locInterface.GetTextForLocalisationKeyResult = new LocalisedText(new LocalisedTextEntries(entries));

            var expectedKey = new LocalisationKey("Testy", "Test");

            var localisedTextRef = new LocalisedTextRef(expectedKey);

            Assert.IsTrue(localisedTextRef.ToString().Equals(localisedTextRef.InternalLocalisedText.ToString()));

            LocalisationManager.CurrentLocalisationInterface = null;
        }
Example #9
0
        public void LocalisedTextRef_QueriesLocalisationManagerToGetLocalisedText()
        {
            var locInterface = new MockLocalisationInterface();

            LocalisationManager.CurrentLocalisationInterface = locInterface;

            var entries = new List <LocalisedTextEntry>
            {
                new LocalisedTextEntry(ELanguageOptions.German, "TEST")
            };

            locInterface.GetTextForLocalisationKeyResult = new LocalisedText(new LocalisedTextEntries(entries));

            var expectedKey = new LocalisationKey("Testy", "Test");

            var localisedTextRef = new LocalisedTextRef(expectedKey);

            Assert.AreSame(expectedKey, locInterface.SubmittedGetTextLocalisationKey);
            Assert.AreSame(locInterface.GetTextForLocalisationKeyResult, localisedTextRef.InternalLocalisedText);

            LocalisationManager.CurrentLocalisationInterface = null;
        }
        public void LocalisationComponent_GetTextForLocalisationKey_NotExisting_ThrowsErrorAndUpdatesDatabaseAsset()
        {
            _localisationComponent.TestAwake();

            var errornousKey = new LocalisationKey("OH NO ERROR", "BAD KEY BADDDDD");

            LogAssert.Expect(LogType.Error, "Could not find key " + errornousKey + "! Adding to loctext file");

            _localisationComponent.GetTextForLocalisationKey(errornousKey);

            var foundKey = false;

            foreach (var localisedEntry in _localisedText.LocalisedDatabase)
            {
                if (localisedEntry.TextKey.Equals(errornousKey))
                {
                    foundKey = true;
                }
            }

            Assert.IsTrue(foundKey);
        }
Example #11
0
 public bool Equals(LocalisationKey inKey)
 {
     return(LocalisationNamespace.Equals(inKey.LocalisationNamespace) &&
            LocalisationKeyValue.Equals(inKey.LocalisationKeyValue));
 }
        public LocalisedText GetTextForLocalisationKey(LocalisationKey inKey)
        {
            SubmittedGetTextLocalisationKey = inKey;

            return(GetTextForLocalisationKeyResult);
        }