public void GetNewsItemTest() { NewsServiceClient client = new NewsServiceClient(); byte[] bytes = Encoding.UTF8.GetBytes("hola mundo"); newsItem nItem = new newsItem() { title = "News Item Title", body = "News Item 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 id = client.ReportNewsItem(nItem); newsItem nItemFromDB = client.GetNewsItem(id); Assert.IsNotNull(nItemFromDB.id); Assert.AreEqual<string>(id, nItemFromDB.id); Assert.AreEqual<string>("News Item Title", nItemFromDB.title); Assert.AreEqual<string>("News Item Body", nItemFromDB.body); Assert.AreEqual<string>("4ab87d67-db83-4364-9ded-d6dd4e616a34", nItemFromDB.reportedBy); client.DeleteNewsItem(id); }
public void ModifyNewsItemTest() { NewsServiceClient client = new NewsServiceClient(); byte[] bytes = Encoding.UTF8.GetBytes("hola mundo"); newsItem nItem = new newsItem() { title = "News Item Title", body = "News Item 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 }; string id = client.ReportNewsItem(nItem); newsItem nItemFromDB = client.GetNewsItem(id); nItemFromDB.title = "Modified title"; nItemFromDB.body = "Modified body"; nItemFromDB.rating = 5; nItemFromDB.ratingSpecified = true; nItemFromDB.reviews = 1; nItemFromDB.reviewsSpecified = true; client.ModifyNewsItem(nItemFromDB); nItemFromDB = client.GetNewsItem(nItemFromDB.id); Assert.IsNotNull(nItemFromDB); Assert.AreEqual<string>(id, nItemFromDB.id); Assert.AreEqual<string>("Modified title", nItemFromDB.title); Assert.AreEqual<string>("Modified body", nItemFromDB.body); Assert.AreEqual<short>(5, nItemFromDB.rating); Assert.AreEqual<int>(1, nItemFromDB.reviews); client.DeleteNewsItem(id); }