This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected virtual IWindsorContainer InitializeServiceLocator() | |
{ | |
var container = new WindsorContainer(); | |
ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container)); | |
// NOTE: Here I need to register each controller | |
ComponentRegistrar.AddComponentsTo(container); | |
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container)); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Moq; | |
using Rioshu.Educa; | |
using Rioshu.Educa.Data; | |
using Rioshu.Educa.Models; | |
using Rioshu.Educa.Services; | |
using Xunit; | |
using Xunit.Extensions; | |
using Machine.Specifications; | |
using It=Machine.Specifications.It; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Subject("Registering a user")] | |
public class when_username_already_exists : Membership_service_subscription_context | |
{ | |
static Exception exception; | |
Because of = () => { | |
signup.Username = "username"; | |
exception = Catch.Exception(() => suo.Register(signup)); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Moq; | |
using Rioshu.Educa; | |
using Rioshu.Educa.Data; | |
using Rioshu.Educa.Models; | |
using Rioshu.Educa.Services; | |
using Machine.Specifications; | |
using It=Machine.Specifications.It; | |
namespace Membership.App.Facts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Subject(typeof(MembershipService), "Registering a user")] | |
public class when_member_data_is_totally_correct : Membership_service_subscription_context | |
{ | |
Because of = () => | |
suo.Register(signup); | |
It should_save_member_to_repository = () => | |
memberRepository.Verify(r => r.Add(Moq.It.Is<Member>(m => m.Username == "non.exists"))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using FluentValidation; | |
using FluentValidation.TestHelper; | |
using Moq; | |
using Rioshu.Educa.Data; | |
using Rioshu.Educa.Models; | |
using Rioshu.Educa.Validators; | |
using Xunit; | |
namespace Membership.App.Facts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text.RegularExpressions; | |
using FluentValidation; | |
using Rioshu.Educa.Data; | |
using Rioshu.Educa.Models; | |
namespace Rioshu.Educa.Validators | |
{ | |
public class SignUpFormValidator : AbstractValidator<SignUpForm> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BlogCommentPosted : IBlogEvent { | |
public BlogComment Comment { get; set; } | |
} | |
public static Class BlogEvent : ICommonEvent | |
{ | |
public static void Raise<T>(T eventArg) | |
where T : ICommonEvent { | |
var events = IoC.Current.ResolveAll<Handles<T>>(); | |
foreach (var @event in events) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
using MvcContrib.Filters; | |
using Rioshu.Educa.Helpers; | |
using Rioshu.Educa.Models; | |
using Rioshu.Educa.NHibernate; | |
using Rioshu.Educa.Services; | |
namespace Rioshu.Educa.Controllers | |
{ | |
[HandleError] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public BlogPostPageView GetPosts(string username) | |
{ | |
Check.Require(username.IsNullOrEmpty(), "username to get a blog must not be emtpy"); | |
var member = memberRepository.GetByUsername(username); | |
if (member == null) | |
throw new InvalidOperationException("Member with username does not exists: {0}".With(username)); | |
var blog = blogRepository.GetBlog(username); | |
if (blog == null) |