コード例 #1
0
        public void GetLatestNewsTest()
        {
            NewsServiceClient client = new NewsServiceClient();

            byte[] bytes = Encoding.UTF8.GetBytes("hola mundo");

            newsItem nItem = new newsItem()
            {
                title = "News Item1 Title",
                body = "News Item1 Body",
                reportedBy = "4ab87d67-db83-4364-9ded-d6dd4e616a34",
                picture = bytes,
                pictureScale = 16.9,
                pictureScaleSpecified = true,
                pictureSize = bytes.Length,
                pictureSizeSpecified = true,
                rating = 10,
                ratingSpecified = true,
                reviews = 50,
                reviewsSpecified = true,
                tags = new string[] { "tag1", "tag2", "tag3" },
                categories = new newsItemEntry[] {
                    new newsItemEntry() { key="sport", value="Sports" },
                    new newsItemEntry() { key="economy", value="Bussiness and Economy" }
                }
            };

            string id1 = client.ReportNewsItem(nItem);

            bytes = Encoding.UTF8.GetBytes("hola guapa");

            nItem = new newsItem()
            {
                title = "News Item2 Title",
                body = "News Item2 Body",
                reportedBy = "4ab87d67-8888-4444-9999-d6dd4e616a34",
                picture = bytes,
                pictureScale = 16.9,
                pictureScaleSpecified = true,
                pictureSize = bytes.Length,
                pictureSizeSpecified = true,
                rating = 10,
                ratingSpecified = true,
                reviews = 50,
                reviewsSpecified = true,
                tags = new string[] { "tag4", "tag5" },
                categories = new newsItemEntry[] {
                    new newsItemEntry() { key="culture", value="Culture and Art" },
                    new newsItemEntry() { key="international", value="International" }
                }
            };

            string id2 = client.ReportNewsItem(nItem);

            newsItem[] latest = client.GetLatestNews(1);

            Assert.IsNotNull(latest);
            Assert.AreEqual<int>(1, latest.Length);

            client.DeleteNewsItem(id1);
            client.DeleteNewsItem(id2);
        }