Exemplo n.º 1
0
        public void EachItem()
        {
            Client listClient = new ClientMock(MockResponse.PresetsList);

            foreach (Preset item in PresetsList.EachItem(listClient))
            {
                Assert.That(listClient, Is.SameAs(item.record.RecordClient));
                Assert.AreEqual(item.record.RecordEndpoint, "encoding_presets");
            }

            var per_page = "1";
            var query    = new Dictionary <string, string>()
            {
                { "per_page", per_page }
            };

            int countItem = 0;

            foreach (Preset item in PresetsList.EachItem(query, listClient))
            {
                countItem++;
            }

            Assert.AreEqual(countItem.ToString(), per_page);
        }
Exemplo n.º 2
0
 public bool RemovePreset(DtoPreset inPreset)
 {
     if (PresetsList != null && PresetsList.Contains(inPreset))
     {
         PresetsList.Remove(inPreset);
         inPreset.EizoActionCalled -= InPreset_EizoActionCalled;
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool AddPreset(DtoPreset inPreset)
 {
     if (PresetsList == null)
     {
         PresetsList = new ObservableCollection <DtoPreset>();
     }
     if (PresetsList != null && !PresetsList.Contains(inPreset))
     {
         inPreset.ParentSmartWall = this;
         PresetsList.Add(inPreset);
         inPreset.EizoActionCalled += InPreset_EizoActionCalled;
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        public void NewPresetsList()
        {
            var list = new PresetsList();

            Assert.AreEqual(list.records.RecordEndpoint, "encoding_presets");
            Assert.IsInstanceOf <List <Record> > (list.records.List);
            Assert.IsInstanceOf <List <Preset> > (list.Page);

            var client = new ClientMock(MockResponse.PresetsList);

            list = new PresetsList(client);

            Assert.AreEqual(list.records.RecordEndpoint, "encoding_presets");
            Assert.IsInstanceOf <List <Record> > (list.records.List);
            Assert.IsInstanceOf <List <Preset> > (list.Page);

            Assert.IsInstanceOf <Client> (list.records.RecordClient);
        }
Exemplo n.º 5
0
        public void Paginate()
        {
            var list = PresetsList.Paginate(new ClientMock(MockResponse.PresetsList));

            var listClient = list.records.RecordClient;

            Assert.AreEqual(list.records.RecordEndpoint, "encoding_presets");

            foreach (var item in list.Page)
            {
                Assert.AreEqual(item.record.RecordEndpoint, "encoding_presets");
            }

            var per_page = "1";
            var query    = new Dictionary <string, string>()
            {
                { "per_page", per_page }
            };

            var list2 = PresetsList.Paginate(query, new ClientMock(MockResponse.PresetsList));

            var countItem = 0;

            foreach (var item in list2.Page)
            {
                countItem++;
            }

            Assert.AreEqual(countItem.ToString(), per_page);

            list = PresetsList.Paginate(new ClientMock(MockResponse.RecordPaginate));

            Assert.IsTrue(list.Next());
            Assert.IsTrue(list.Prevous());
            Assert.IsTrue(list.First());
            Assert.IsTrue(list.Last());

            list = PresetsList.Paginate(new ClientMock(MockResponse.RecordPaginateEmpty));

            Assert.IsFalse(list.Next());
            Assert.IsFalse(list.Prevous());
            Assert.IsFalse(list.First());
            Assert.IsFalse(list.Last());
        }
Exemplo n.º 6
0
        /// <summary> Populate the UI with the preset with the specified name. </summary>
        public void LoadPreset(string name)
        {
            if (!PresetsList.Any(p => p.Name == name))
            {
                return;
            }

            var pr = PresetsList.Where(p => p.Name == name).First();

            // Must clear any filters or units might not be selectable
            if (ShowFilter)
            {
                SelectedFilter = Filters.First();
            }

            // Override dropdowns with preset
            SelectedUnit1 = FindUnit(pr.Character1, Units);
            SelectedUnit2 = FindUnit(pr.Character2, Units);
            SelectedUnit3 = FindUnit(pr.Character3, Units);
            SelectedUnit4 = FindUnit(pr.Character4, Units);
            SelectedUnit5 = FindUnit(pr.Character5, Units);
        }
Exemplo n.º 7
0
        public SquadFinderViewmodel(PlayerList members, IEnumerable <UnitDetails> unitDetails)
        {
            Members     = members ?? throw new ArgumentNullException("members");
            UnitDetails = unitDetails;

            ShowFilter = UnitDetails != null;

            SearchCommand = new SimpleCommand(DoSearch);

            BuildUnitList();
            UnitSource1 = new CollectionViewSource {
                Source = Units
            };
            UnitSource1.Filter += FilterUnits;
            UnitSource2         = new CollectionViewSource {
                Source = Units
            };
            UnitSource2.Filter += FilterUnits;
            UnitSource3         = new CollectionViewSource {
                Source = Units
            };
            UnitSource3.Filter += FilterUnits;
            UnitSource4         = new CollectionViewSource {
                Source = Units
            };
            UnitSource4.Filter += FilterUnits;
            UnitSource5         = new CollectionViewSource {
                Source = Units
            };
            UnitSource5.Filter += FilterUnits;

            BuildFilterList();
            SelectedFilter = Filters.FirstOrDefault();

            PresetsList = SquadPreset.LoadPresets();
            ShowPresets = PresetsList.Any();
        }
Exemplo n.º 8
0
        //Read EncodingPresets
        public static void ReadingEncodingPresetsList(string id, string token)
        {
            try {
                Console.WriteLine("--EachItem()--");
                foreach (Preset item in PresetsList.EachItem())
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--EachItem(query)--");

                Dictionary <string, string> query = new Dictionary <string, string>()
                {
                    { "sort", "id" },
                    { "order", "desc" },
                    { "per_page", "2" }
                };

                Client client = new Client()
                {
                    CfgClientId = id, CfgAuthToken = token
                };
                foreach (var item in PresetsList.EachItem(query, client))
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--Paginate--");

                var items1 = PresetsList.Paginate();
                foreach (var item in items1.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--Paginate(query)--");

                var items2 = PresetsList.Paginate(query, new Client());

                Console.WriteLine("--Paginate(query)--Initial-First--");
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                while (items2.Next())
                {
                    Console.WriteLine("--Paginate(query)--Next--");

                    foreach (var item in items2.Page)
                    {
                        Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                    }
                }

                Console.WriteLine("--Paginate(query)--Previous--");
                items2.Prevous();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--Paginate(query)--Last--");
                items2.Last();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--Paginate(query)--First--");
                items2.First();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);
                }

                Console.WriteLine("--Rate Information--");
                var client3 = items2.GetClient();

                Console.WriteLine("RateLimit: " + client3.RateLimit);
                Console.WriteLine("RateRemaining: " + client3.RateRemaining);
                Console.WriteLine("RateReset: " + client3.RateReset);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }