view Agendas/trunk/src/Agendas.Tests/Blog/PostWriterWebServiceAdapterTests.cs @ 103:23325dddddcc

Persistencia del estado de los eventos
author jorge.rowies
date Sun, 05 Jun 2011 13:06:23 -0300
parents 3027c64344bd
children 1d820f17fc75
line wrap: on
line source

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.ServiceModel;
using System.Text;
using Agendas.Blog;
using Agendas.Blog.Exceptions;
using Agendas.Blog.Impl;
using AltNetHispano.Agendas.Domain;
using Moq;
using NUnit.Framework;

namespace AltNetHispano.Agendas.Tests.Blog
{
  [TestFixture]
  public class PostWriterWebServiceAdapterTests
  {
    [SetUp]
    public void ClearAppSettings()
    {
      ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"] = "";
      ConfigurationManager.AppSettings["PublicadorBlog.BlogName"] = "";
      ConfigurationManager.AppSettings["PublicadorBlog.BlogWriterMasterKey"] = "";
    }

    [Test]
    [ExpectedException(typeof(EndpointNotFoundException))]
    public void Si_la_url_es_invalida_debe_lanzar_excepcion()
    {
      ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"] = "http://dummy/dummy.aspx";
      ConfigurationManager.AppSettings["PublicadorBlog.BlogName"] = "dummy";
      ConfigurationManager.AppSettings["PublicadorBlog.BlogWriterMasterKey"] = "dummy";

      var srv = new PostWriterWebServiceAdapter();
      srv.WriteBlogPost(null, null, null, false);
    }

    [Test]
    [ExpectedException(typeof(PostWriterServiceUrlNotFoundException))]
    public void Si_la_url_no_esta_configurada_debe_lanzar_excepcion()
    {
      var srv = new PostWriterWebServiceAdapter();
      srv.WriteBlogPost(null, null, null, false);
    }

    [Test]
    [ExpectedException(typeof(BlogNameNotFoundException))]
    public void Si_el_nombre_del_blog_no_esta_configurado_debe_lanzar_excepcion()
    {
      ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"] = "http://dummy/dummy.aspx";
      ConfigurationManager.AppSettings["PublicadorBlog.BlogWriterMasterKey"] = "dummy";

      var srv = new PostWriterWebServiceAdapter();
      srv.WriteBlogPost(null, null, null, false);
    }

    [Test]
    [ExpectedException(typeof(BlogWriterMasterKeyNotFoundException))]
    public void Si_la_master_key_no_esta_configurada_debe_lanzar_excepcion()
    {
      ConfigurationManager.AppSettings["PublicadorBlog.PostWriterServiceUrl"] = "http://dummy/dummy.aspx";

      var srv = new PostWriterWebServiceAdapter();
      srv.WriteBlogPost(null, null, null, false);
    }
  }

}