public void BeforeUserRegisteredAllow()
        {
            var membershipRepository = Substitute.For<IMembershipRepository>();

            var settingsRepository = Substitute.For<ISettingsRepository>();
            settingsRepository.GetSettings().Returns(new Settings { NewMemberStartingRole = new MembershipRole{RoleName = "Test"} });
           
            var emailService = Substitute.For<IEmailService>();
            var localisationService = Substitute.For<ILocalizationService>();

            var membershipService = new MembershipService(membershipRepository, settingsRepository, emailService, localisationService, _activityService, _privateMessageService,
                _membershipUserPointsService, _topicNotificationService, _voteService, _badgeService, _categoryNotificationService, _api, _loggingService);
            EventManager.Instance.BeforeRegisterUser += EventManagerInstance_BeforeRegisterUserAllow;

            var newUser = new MembershipUser { UserName = "******", Password = "******" };
            membershipRepository.GetUser(newUser.UserName).Returns(x => null);
            membershipService.CreateUser(newUser);

            membershipRepository.Received().Add(Arg.Is<MembershipUser>(x => x.UserName == "SpongeBob"));
            Assert.AreEqual(newUser.Email, TestString);
            EventManager.Instance.BeforeRegisterUser -= EventManagerInstance_BeforeRegisterUserAllow;
        }
        public void BeforeUserRegisteredCancel()
        {
            var membershipRepository = Substitute.For<IMembershipRepository>();

            var settingsRepository = Substitute.For<ISettingsRepository>();
            var emailService = Substitute.For<IEmailService>();
            var localisationService = Substitute.For<ILocalizationService>();

            var membershipService = new MembershipService(membershipRepository, settingsRepository, emailService, localisationService, _activityService, _privateMessageService,
                _membershipUserPointsService, _topicNotificationService, _voteService, _badgeService, _categoryNotificationService, _api, _loggingService);
            EventManager.Instance.BeforeRegisterUser += EventManagerInstance_BeforeRegisterUserCancel;

            var newUser = new MembershipUser { UserName = "******", Password = "******" };
            membershipRepository.GetUser(newUser.UserName).Returns(x => null);
            membershipService.CreateUser(newUser);

            membershipRepository.DidNotReceive().Add(Arg.Is<MembershipUser>(x => x.UserName == "SpongeBob"));
            EventManager.Instance.BeforeRegisterUser -= EventManagerInstance_BeforeRegisterUserCancel;
        }