/// <summary>
 /// Initializes the Storage Provider.
 /// </summary>
 /// <param name="host">The Host of the Component.</param>
 /// <param name="config">The Configuration data, if any.</param>
 /// <param name="wiki">The wiki.</param>
 /// <remarks>If the configuration string is not valid, the methoud should throw a <see cref="InvalidConfigurationException"/>.</remarks>
 public void Init(IHostV40 host, string config, string wiki)
 {
     this.host       = host;
     this.config     = config != null ? config : "";
     this.wiki       = string.IsNullOrEmpty(wiki) ? "root" : wiki;
     defaultLanguage = host.GetSettingValue(SettingName.DefaultLanguage);
     displayWarning  = config.ToLowerInvariant().Equals("display warning");
 }
        /// <summary>
        /// Gets the recent changes of the Wiki.
        /// </summary>
        /// <returns>The recent Changes, oldest to newest.</returns>
        public RecentChange[] GetRecentChanges()
        {
            try {
                var query = (from e in _context.CreateQuery <RecentChangesEntity>(RecentChangesTable).AsTableServiceQuery()
                             where e.PartitionKey.Equals(_wiki)
                             select e).Take((int)(int.Parse(_host.GetSettingValue(SettingName.MaxRecentChanges)) * 0.90)).AsTableServiceQuery();
                IList <RecentChangesEntity> recentChangesEntities = QueryHelper <RecentChangesEntity> .All(query);

                List <RecentChange> recentChanges = new List <RecentChange>(recentChangesEntities.Count);
                foreach (RecentChangesEntity entity in recentChangesEntities)
                {
                    recentChanges.Add(new RecentChange(entity.Page, entity.Title, entity.MessageSubject + "", new DateTime(entity.DateTime.Ticks, DateTimeKind.Utc), entity.User, GetChange(entity.Change), entity.Description + ""));
                }
                return(recentChanges.ToArray());
            }
            catch (Exception ex) {
                throw ex;
            }
        }
        protected IHostV40 MockHost()
        {
            if (!Directory.Exists(testDir))
            {
                Directory.CreateDirectory(testDir);
            }
            //Console.WriteLine("Temp dir: " + testDir);

            IHostV40 host = mocks.DynamicMock <IHostV40>();

            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.PublicDirectory)).Return(testDir).Repeat.AtLeastOnce();

            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.LoggingLevel)).Return("3").Repeat.Any();
            Expect.Call(host.GetGlobalSettingValue(GlobalSettingName.MaxLogSize)).Return(MaxLogSize.ToString()).Repeat.Any();
            Expect.Call(host.GetSettingValue(SettingName.MaxRecentChanges)).Constraints(Rhino.Mocks.Constraints.Is.Equal(SettingName.MaxRecentChanges)).Return(MaxRecentChanges.ToString()).Repeat.Any();

            mocks.Replay(host);

            return(host);
        }