protected override void Establish_context()
		{
			_sut = new EventPlugin(MockRepository.GenerateMock<IPostRepository>(),
								   MockRepository.GenerateMock<IMapper<NameValueCollection, Settings>>(),
								   MockRepository.GenerateMock<IValidator<Settings>>());

			_post = MockRepository.GenerateStub<DataBuddyBase>();
		}
Пример #2
0
        private void ExecuteDataObjectEvent(object key, DataBuddyBase dbb)
        {
            DataObjectEventHandler doe = Events[key] as DataObjectEventHandler;

            if (doe != null)
            {
                doe(dbb, EventArgs.Empty);
            }
        }
Пример #3
0
		protected override void Establish_context()
		{
			base.Establish_context();

			_sut = Container.Create<TalkPlugin>();

			_post = MockRepository.GenerateStub<DataBuddyBase>();

			Mocks.ReplayAll();
		}
Пример #4
0
 private void ExecuteDataObjectEvent(object key, DataBuddyBase dbb)
 {
     DataObjectEventHandler doe = Events[key] as DataObjectEventHandler;
     if (doe != null)
     {
         doe(dbb, EventArgs.Empty);
     }
 }
Пример #5
0
		internal void Post_Validate(DataBuddyBase dataObject, EventArgs e)
		{
			if (!EnableEventHandlers)
			{
				return;
			}

			Post post = dataObject as Post;
			if (post == null)
			{
				return;
			}

			if (!_postRepository.GetCategoryNameOf(post).Equals(CategoryName, StringComparison.OrdinalIgnoreCase))
			{
				return;
			}

			var validation = IoC.Resolve<ITalkValidator>(this).Validate(post).Interpret();
			if (validation.Failed)
			{
				validation.ThrowAsException();
			}
		}
Пример #6
0
 /// <summary>
 ///     Executes the BeforeDestroy Vent
 /// </summary>
 internal void ExecuteBeforeDestroyEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeDestroyObject, dbb);
 }
Пример #7
0
 /// <summary>
 ///     Executes the BeforeRemove Vent
 /// </summary>
 internal void ExecuteBeforeRemoveEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeRemoveObject, dbb);
 }
Пример #8
0
 /// <summary>
 ///     Executes the AfterCommit Vent
 /// </summary>
 internal void ExecuteAfterCommitEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterCommitObject, dbb);
 }
Пример #9
0
 /// <summary>
 ///     Executes the BeforeInsert Vent
 /// </summary>
 internal void ExecuteBeforeInsertEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeInsertObject, dbb);
 }
Пример #10
0
 /// <summary>
 /// Executes the AfterInsert Vent
 /// </summary>
 internal void ExecuteAfterInsertEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterInsertObject, dbb);
 }
Пример #11
0
 /// <summary>
 /// Executes the AfterDestroy Vent
 /// </summary>
 internal void ExecuteAfterDestroyEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterDestroyObject, dbb);
 }
Пример #12
0
 /// <summary>
 /// Executes the AfterCommit Vent
 /// </summary>
 internal void ExecuteAfterCommitEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterCommitObject, dbb);
 }
        /// <summary>
        /// Called after an item has been committed.
        /// </summary>
        /// <param name="dataObject">The data object.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected virtual void OnAfterCommit(DataBuddyBase dataObject, EventArgs e)
        {
            // We only care about posts
            Post post = dataObject as Post;
            if (post == null)
                return;

            // Determine if we should tweet this post
            if (!ShouldTweet(post))
                return;

            try
            {
                // We've made it this far...the post is being published for the first time...alert the twitterverse!
                string updateText = FormatTweet(post);

                if (updateText.Length > 140)
                {
                    Log.Warn(this.Name, "Unable to format '{0}' for twitter.", post.Title);
                    return;
                }

                TwitterClient.UpdateStatus(this.Username, this.Password, updateText);
            }
            catch (WebException ex)
            {
                Log.Error("Twitter Notify", ex.Message);
            }
        }
Пример #14
0
        void ga_AfterUpdate(DataBuddyBase dataObject, EventArgs e)
        {
            Post post = dataObject as Post;

            if (post != null)
            {
                // Check that post
                //  1. Is Published
                //  2. The current verison is set to be published
                //  3. Was not published within the last 10 seconds (some plugins update the post immediately after it is created,
                //     which can cause double trackbacks/pings)
                if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddSeconds(-10.0)) <= 0)
                {
                    // Blog Pings
                    if (EnablePings)
                        XmlRpcPings.SendPings(post, PingUrls);

                    // Check for links to send Trackbacks & Pingbacks
                    if (EnableTrackbacks)
                        LinkParser.CheckPost(post);
                }

            }
        }
Пример #15
0
        void ga_AfterInsert(DataBuddyBase dataObject, EventArgs e)
        {
            Post post = dataObject as Post;

            if (post != null)
            {
                // Check that post
                //  1. Is Published
                //  2. The current verison is set to be published
                //  3. Is not a future dated post
                if (post.IsPublished && post.PostStatus == PostStatus.Publish && post.Published.CompareTo(DateTime.UtcNow.AddMinutes(1.0)) <= 0)
                {
                    // Blog Pings
                    if (EnablePings)
                        XmlRpcPings.SendPings(post, PingUrls);

                    // Check for links to send Trackbacks & Pingbacks
                    if (EnableTrackbacks)
                        LinkParser.CheckPost(post);
                }

            }
        }
Пример #16
0
 /// <summary>
 /// Executes the AfterUpdate Vent
 /// </summary>
 internal void ExecuteAfterUpdateEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterUpdateObject, dbb);
 }
Пример #17
0
 /// <summary>
 /// Executes the BeforeDestroy Vent
 /// </summary>
 internal void ExecuteBeforeDestroyEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeDestroyObject, dbb);
 }
Пример #18
0
 /// <summary>
 ///     Executes the BeforeUpdate Vent
 /// </summary>
 internal void ExecuteBeforeUpdateEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeUpdateOjbect, dbb);
 }
Пример #19
0
 /// <summary>
 /// Executes the BeforeInsert Vent
 /// </summary>
 internal void ExecuteBeforeInsertEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeInsertObject, dbb);
 }
Пример #20
0
 /// <summary>
 ///     Executes the AfterInsert Vent
 /// </summary>
 internal void ExecuteAfterInsertEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterInsertObject, dbb);
 }
Пример #21
0
 /// <summary>
 /// Executes the BeforeRemove Vent
 /// </summary>
 internal void ExecuteBeforeRemoveEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeRemoveObject, dbb);
 }
Пример #22
0
 /// <summary>
 ///     Executes the AfterRemove Vent
 /// </summary>
 internal void ExecuteAfterRemoveEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterRemoveObject, dbb);
 }
Пример #23
0
 /// <summary>
 /// Executes the BeforeValidate Vent
 /// </summary>
 internal void ExecuteBeforeValidateEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(BeforeValidateObject, dbb);
 }
Пример #24
0
 /// <summary>
 ///     Executes the AfterDestroy Vent
 /// </summary>
 internal void ExecuteAfterDestroyEvent(DataBuddyBase dbb)
 {
     ExecuteDataObjectEvent(AfterDestroyObject, dbb);
 }
Пример #25
0
		internal void Post_SetDefaultValues(DataBuddyBase dataObject, EventArgs e)
		{
			if (!EnableEventHandlers)
			{
				return;
			}

			Post post = dataObject as Post;
			if (post == null)
			{
				return;
			}

			if (!_postRepository.GetCategoryNameOf(post).Equals(CategoryName, StringComparison.OrdinalIgnoreCase))
			{
				return;
			}

			// Set default location if no location is given.
			if (!post[LocationUnknownField].IsSelected() && post[LocationField].IsNullOrEmpty())
			{
				post[LocationField] = DefaultLocation;
				post.ForcePropertyUpdate();
			}

			// Set default number maximum number of registrations.
			if (post[MaximumNumberOfRegistrationsField].IsNullOrEmpty())
			{
				post[MaximumNumberOfRegistrationsField] = DefaultMaximumNumberOfRegistrations;
				post.ForcePropertyUpdate();
			}

			// Set default registration recipient.
			if (post[RegistrationRecipientField].IsNullOrEmpty())
			{
				post[RegistrationRecipientField] = DefaultRegistrationRecipient;
				post.ForcePropertyUpdate();
			}
		}