コード例 #1
0
        public void Convert()
        {
            var entry = new BlogEntry()
            {
                Content           = StringHelper.ValidString(),
                Identifier        = Guid.NewGuid(),
                SectionIdentifier = Guid.NewGuid(),
                Title             = StringHelper.ValidString(),
                PostedOn          = DateTime.UtcNow,
            };

            var converted = entry.Convert();

            Assert.AreEqual <string>(entry.SectionIdentifier.ToString(), converted.PartitionKey);
            Assert.AreEqual <string>(entry.Title, converted.Title);
            Assert.AreEqual <string>(entry.Identifier.ToString(), converted.RowKey);
            Assert.AreEqual <DateTime>(entry.PostedOn, converted.PostedOn);
        }
コード例 #2
0
        /// <summary>
        /// Blog Entry
        /// </summary>
        /// <param name="entry">Blog Entry</param>
        /// <returns>Blog Entry</returns>
        public BlogEntry Store(BlogEntry entry)
        {
            Contract.Requires <ArgumentNullException>(null != entry);
            Contract.Requires <ArgumentException>(Guid.Empty != entry.SectionIdentifier);
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(entry.Title));
            Contract.Requires <ArgumentException>(!string.IsNullOrWhiteSpace(entry.Content));

            Contract.Ensures(Contract.Result <BlogEntry>() != null);

            using (new PerformanceMonitor())
            {
                entry.Identifier = this.source.InsertText(entry.Content);

                var table = new AzureTable <BlogRow>(ServerConfiguration.Default);
                table.AddEntity(entry.Convert());
            }

            return(entry);
        }