Example #1
0
        public void BasicUsagePasses()
        {
            var resource      = new TextResources();
            var formattedKey1 = "formattedKey";
            var normalKey     = "normalKey";

            resource
            .Add(formattedKey1, "Apple is {0}.")
            .Add(normalKey, "Orange is furits.");

            Assert.AreEqual(2, resource.Count);
            Assert.AreEqual("Apple is 100.", resource.Get(formattedKey1, 100));
            Assert.AreEqual("Orange is furits.", resource.Get(normalKey));
            Assert.IsTrue(resource.Contains(normalKey));
            Assert.IsTrue(resource.Contains(formattedKey1));
            Debug.Log($"Success to Add and Get Methods!");

            {
                resource.Dispose();
                Assert.AreEqual(0, resource.Count);
                Assert.Throws <UnityEngine.Assertions.AssertionException>(() => {
                    Assert.AreEqual("Apple is 100.", resource.Get(formattedKey1, 100));
                });
                Assert.Throws <UnityEngine.Assertions.AssertionException>(() => {
                    Assert.AreEqual("Orange is furits.", resource.Get(normalKey));
                });
                Assert.IsFalse(resource.Contains(normalKey));
                Assert.IsFalse(resource.Contains(formattedKey1));
            }
            Debug.Log($"Success to Dispose!");
        }
Example #2
0
 public static void SetTexts(this IHavingDialogData data, DialogModel target, TextResources textResources)
 {
     if (textResources.Contains(data.DialogTitleTextResource))
     {
         target.Title = textResources.Get(data.DialogTitleTextResource);
     }
     if (textResources.Contains(data.DialogTextTextResource))
     {
         target.Text = textResources.Get(data.DialogTextTextResource);
     }
     //Debug.Log($"pass Title={target.Title} Text={target.Text}");
 }
Example #3
0
        public void TextResourceContainsPasses()
        {
            var resources = new TextResources()
                            .Add("key1", "{0}, {1}, {2}");

            var data = new HavingTextResourceData()
            {
                HavingTextResourceKey = "key1",
            };
            var paramList = new object[]
            {
                100,
                "Apple",
                1.23f,
            };

            data.SetParams(paramList);

            Assert.IsTrue(resources.Contains(data));
        }