Beispiel #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!");
        }
Beispiel #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}");
 }
Beispiel #3
0
        public void CreatePasses()
        {
            var data      = HavingTextResourceData.Create("key1", 100, "Apple");
            var resources = new TextResources()
                            .Add("key1", "This is {0}, {1}.");

            Assert.AreEqual("This is 100, Apple.", resources.Get(data));
        }
Beispiel #4
0
        public void TextResourceGetPasses()
        {
            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.AreEqual("100, Apple, 1.23", resources.Get(data));
        }