示例#1
0
        public void testGetter()
        {
            DataProvider dataProvider = new DataProvider();
            SampleDataGroup dataSource = new SampleDataGroup("1","test","subtest","none","desc");

            dataProvider.setGroup(dataSource);

            Assert.AreEqual(dataSource, dataProvider.getGroup(0));
        }
示例#2
0
        public void testPersistence()
        {
            DataProvider dataProvider = new DataProvider();
            SampleDataGroup dataSource = new SampleDataGroup("1", "test", "subtest", "none", "desc");

            DataProvider dataProvider2 = new DataProvider();
            SampleDataGroup dataSource2 = new SampleDataGroup("2", "test2", "subtest2", "none2", "desc2");

            dataProvider.setGroup(dataSource);
            dataProvider2.setGroup(dataSource2);

            Assert.AreEqual(8, dataProvider2.getCount());
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            // TODO: Add dynamic data here
            DataProvider dataProvider = new DataProvider();

            String ITEM_CONTENT = String.Format("Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
                       "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat");
            var group = new SampleDataGroup("Awesome group",
                    "Group Title: 1",
                    "Group Subtitle: 1",
                    "Assets/DarkGray.png",
                    "Group Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus tempor scelerisque lorem in vehicula. Aliquam tincidunt, lacus ut sagittis tristique, turpis massa volutpat augue, eu rutrum ligula ante a ante");
            group.Items.Add(new SampleDataItem("Group-1-Item-1",
                    "Item Title: 1",
                    "Item Subtitle: 1",
                    "Assets/LightGray.png",
                    "Item Description: Pellentesque porta, mauris quis interdum vehicula, urna sapien ultrices velit, nec venenatis dui odio in augue. Cras posuere, enim a cursus convallis, neque turpis malesuada erat, ut adipiscing neque tortor ac erat.",
                    ITEM_CONTENT,
                    group));
            group.Items.Add(new SampleDataItem("Group-1-Item-2",
                    "Item Title: 2",
                    "Item Subtitle: 2",
                    "Assets/DarkGray.png",
                    "Item Description: Pellentesque porta, mauris quis interdum vehicula, urna sapien ultrices velit, nec venenatis dui odio in augue. Cras posuere, enim a cursus convallis, neque turpis malesuada erat, ut adipiscing neque tortor ac erat.",
                    ITEM_CONTENT,
                    group));

            dataProvider.setGroup(group);
            //httpRequest to fetch all data
            //httpRequest("titles");
            dataProvider.httpRequest("titles&tutorials");
            
            var sampleDataGroups = SampleDataSource.GetGroups((String)navigationParameter);
            
            this.DefaultViewModel["Items"] = sampleDataGroups;
        }
示例#4
0
        public void testXmlReading()
        {
            DataProvider dataProvider = new DataProvider();
            XDocument testDoc = XDocument.Parse("<document>                                                                     " +
            "                                  <story>                                       " +
            "                                    <uid>Tove</uid>                              " +
            "                                    <title>Tove</title>                              " +
            "                                    <subtitle>Jani</subtitle>                          " +
            "                                    <image>Reminder</image>                " +
            "                                    <description>Don't forget me this weekend!</description> " +
            "                                  </story>                                      " +
            "                                  <story>                                       " +
            "                                    <uid>Dove</uid>                              " +
            "                                    <title>Someone special</title>                   " +
            "                                    <subtitle>Janina</subtitle>                        " +
            "                                    <image>Miner</image>                   " +
            "                                    <description>forget me !</description>                   " +
            "                                  </story>                                      " +
            "                                </document>");

            //dataProvider.readXmlNode(testDoc);

            //Assert.AreEqual(10, dataProvider.getCount());
        }
        public async void httpRequest(string sParams)
        {
            //Task<string> sResponse;
            try
            {
                var httpClient = new HttpClient();
                var url = new Uri("http://codecamp/index.php?" + sParams);
                var accessToken = "1234";
                var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url);

                httpRequestMessage.Headers.Add(System.Net.HttpRequestHeader.Authorization.ToString(), string.Format("Bearer {0}", accessToken));
                httpRequestMessage.Headers.Add("User-Agent", "My user-Agent");
                var response = await httpClient.SendAsync(httpRequestMessage);
                DataProvider dataProvider = new DataProvider();

                var sStream = await response.Content.ReadAsStringAsync();
                var doc = XDocument.Parse(sStream);

                DataProvider.readXmlNode(doc);



                //sResponse = response.ToString();
            }
            catch (Exception e)
            {

            }
        }
        public SampleDataSource()
        {
            // this should load local data, cause it's executed once
            DataProvider.readData();
            // TODO: delete this at the end.
            String ITEM_CONTENT = String.Format("Item Content: {0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}\n\n{0}",
                        "Curabitur class aliquam vestibulum nam curae maecenas sed integer cras phasellus suspendisse quisque donec dis praesent accumsan bibendum pellentesque condimentum adipiscing etiam consequat vivamus dictumst aliquam duis convallis scelerisque est parturient ullamcorper aliquet fusce suspendisse nunc hac eleifend amet blandit facilisi condimentum commodo scelerisque faucibus aenean ullamcorper ante mauris dignissim consectetuer nullam lorem vestibulum habitant conubia elementum pellentesque morbi facilisis arcu sollicitudin diam cubilia aptent vestibulum auctor eget dapibus pellentesque inceptos leo egestas interdum nulla consectetuer suspendisse adipiscing pellentesque proin lobortis sollicitudin augue elit mus congue fermentum parturient fringilla euismod feugiat");

            DataProvider dataProvider = new DataProvider();
            var group = new SampleDataGroup("Group-1",
                    "Group Title: 1",
                    "Group Subtitle: 1",
                    "Assets/DarkGray.png",
                    "smaller to see where it is");
            group.Items.Add(new SampleDataItem("Group-1-Item-1",
                    "Item Title: 1",
                    "Item Subtitle: 1",
                    "Assets/LightGray.png",
                    "Item Description: Pellentesque porta, mauris quis interdum vehicula, urna sapien ultrices velit, nec venenatis dui odio in augue. Cras posuere, enim a cursus convallis, neque turpis malesuada erat, ut adipiscing neque tortor ac erat.",
                    ITEM_CONTENT,
                    group));
            group.Items.Add(new SampleDataItem("Group-1-Item-2",
                    "Item Title: 2",
                    "Item Subtitle: 2",
                    "Assets/DarkGray.png",
                    "Item Description: Pellentesque porta, mauris quis interdum vehicula, urna sapien ultrices velit, nec venenatis dui odio in augue. Cras posuere, enim a cursus convallis, neque turpis malesuada erat, ut adipiscing neque tortor ac erat.",
                    ITEM_CONTENT,
                    group));

            dataProvider.setGroup(group);
            //var group1 = dataProvider.getGroup(1);
            //

            //  dataProvider.getData();
            int iCount = dataProvider.getCount();
            if (iCount > 0)
            {
                for (int i = 0; i < iCount; i++)
                {
                    group = dataProvider.getGroup(i);

                    this.AllGroups.Add(group);
                }
            }
        }