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 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));
        }
Example #3
0
        public void LoadAllResources()
        {
            TextResources textResourcesManager = new TextResources(textResourcesWithTwoKeysPath);

            textResourcesManager.LoadResources();

            Assert.AreEqual(2, textResourcesManager.Values.Count);
        }
Example #4
0
        public void LoadValues()
        {
            TextResources textResourcesManager = new TextResources(textResourcesWithTwoKeysPath);

            textResourcesManager.LoadResources();

            Assert.AreEqual("value 1", textResourcesManager.Values["key1"]);
            Assert.AreEqual("value 2", textResourcesManager.Values["key2"]);
        }
Example #5
0
        public void LoadKeys()
        {
            TextResources textResourcesManager = new TextResources(textResourcesWithTwoKeysPath);

            textResourcesManager.LoadResources();

            Assert.IsTrue(textResourcesManager.Values.ContainsKey("key1"));
            Assert.IsTrue(textResourcesManager.Values.ContainsKey("key2"));
        }
Example #6
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 #7
0
        private void CreateTeams()
        {
            string[] TeamFirstName = TextResources.TeamList(TeamListResource.Place, ResourceLanguage.en);
            string[] TeamLastName  = TextResources.TeamList(TeamListResource.Suffix, ResourceLanguage.en);

            List <string> AvailableNames = new List <string>();

            Maths         rand    = new Maths();
            LeagueAdapter la      = new LeagueAdapter();
            TeamAdapter   ta      = new TeamAdapter();
            List <League> Leagues = la.GetLeagues();

            foreach (League L in Leagues)
            {
                for (int i = 0; i <= MAXTEAMSPERLEAGUE - 1; i++)
                {
                    if (AvailableNames.Count == 0)
                    {
                        AvailableNames = TeamFirstName.ToList();
                    }

                    int r;

                    Team NewTeam = new Team();
                    NewTeam.SeasonStatistics = new TeamStats();

                    r            = rand.RandomInclusive(0, AvailableNames.Count - 1);
                    NewTeam.Name = AvailableNames[r] + " ";
                    AvailableNames.RemoveAt(r);

                    r                        = rand.RandomInclusive(0, TeamLastName.GetUpperBound(0));
                    NewTeam.Name             = NewTeam.Name + TeamLastName[r];
                    NewTeam.LeagueID         = L.UniqueID;
                    NewTeam.CurrentFormation = rand.RandomInclusive(0, maxFormationID);


                    int NewID = ta.AddTeam(NewTeam);
                    AssignPlayersToTeam(NewID, L.PlayerEffectivenessBase);

                    // TODO: Temporary AI manager assignment needs replacing
                    Manager NewManager = new Manager();
                    NewManager.FirstName   = "Alan";
                    NewManager.LastName    = NewTeam.Name.Split(Convert.ToChar(" "))[0];
                    NewManager.DateOfBirth = new DateTime(1966, 9, 26);
                    NewManager.Reputation  = rand.RandomInclusive(30, 90);

                    ManagerAdapter ma           = new ManagerAdapter();
                    int            NewManagerID = ma.AddManager(NewManager);
                    ma.AssignToTeam(NewManagerID, NewID);
                }
            }
        }
Example #8
0
        public async void Approve()
        {
            if (TextResource != null)
            {
                NetworkConnectionActive = true;
                var operation = TableOperation.InsertOrReplace(TextResource);
                TextResource.LastUpdatedDate = DateTime.Now;
                TextResource.Approved        = true;
                TextResources.Remove(TextResource);
                await _table.ExecuteAsync(operation);

                TextResource            = null;
                TextResourceCopy        = null;
                NetworkConnectionActive = false;
            }
        }
Example #9
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));
        }
Example #10
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));
        }
Example #11
0
        public async void Save()
        {
            if (TextResource != null)
            {
                NetworkConnectionActive = true;
                var addChangedOperation = TableOperation.InsertOrReplace(TextResourceCopy);
                TextResourceCopy.CreationDate    = DateTime.Now;
                TextResourceCopy.LastUpdatedDate = DateTime.Now;
                await _edits.ExecuteAsync(addChangedOperation);

                TextResource.Edits           = true;
                TextResource.LastUpdatedDate = DateTime.Now;

                var replaceOperation = TableOperation.Replace(TextResource);
                await _table.ExecuteAsync(replaceOperation);

                TextResources.Remove(TextResource);

                TextResource            = null;
                TextResourceCopy        = null;
                NetworkConnectionActive = false;
            }
        }
Example #12
0
        public static OnEventInterruptCallback CreateDialogOnEventInterrupted(DialogType dialogType, TextResources textResources)
        {
            return((binderInstanceMap, interruptedData) => {
                var dialogModel = new DialogModel();
                switch (dialogType)
                {
                case DialogType.OKCancel:
                    dialogModel
                    .AddButton("OK", "OK", new ModelIDList(DialogModel.DIALOG_OK_BUTTON_ID))
                    .AddButton("Cancel", "Cancel", new ModelIDList(DialogModel.DIALOG_CANCEL_BUTTON_ID));
                    break;

                case DialogType.YesNoCancel:
                    dialogModel
                    .AddButton("Yes", "Yes", new ModelIDList(DialogModel.DIALOG_YES_BUTTON_ID))
                    .AddButton("No", "No", new ModelIDList(DialogModel.DIALOG_NO_BUTTON_ID))
                    .AddButton("Cancel", "Cancel", new ModelIDList(DialogModel.DIALOG_CANCEL_BUTTON_ID));
                    break;
                }

                if (interruptedData.SenderModel is IHavingDialogData)
                {
                    var dialogData = interruptedData.SenderModel as IHavingDialogData;
                    dialogData.SetTexts(dialogModel, textResources);
                }
                return (dialogModel, false);
            });
        }
Example #13
0
 private void CreatePlayers()
 {
     string[]             FirstName = TextResources.NameList(NameListResource.FirstNames, ResourceLanguage.en);
     string[]             LastName  = TextResources.NameList(NameListResource.LastNames, ResourceLanguage.en);
     (int min, int max)[] Ranges    = { (0, 40), (20, 60), (40, 80), (60, 100) };