public void ReplaceTokens_Should_Replace_All_Tokens_From_Model()
        {
            // Arrange
            EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _repository, _emailClientMock);
            UserViewModel     userModel     = new UserViewModel();

            userModel.ActivationKey    = "key";
            userModel.ExistingUsername = "******";
            userModel.Firstname        = "firstname";
            userModel.Id               = Guid.NewGuid();
            userModel.Lastname         = "lastname";
            userModel.NewEmail         = "NewEmail";
            userModel.PasswordResetKey = "resetkey";

            SiteSettings siteSettings = new SiteSettings();

            siteSettings.SiteName = "MySite";
            siteSettings.SiteUrl  = "http://www.roadkillwiki.iz.de.biz";
            _repository.SaveSiteSettings(siteSettings);

            StringBuilder templateBuilder = new StringBuilder();

            templateBuilder.AppendLine("{FIRSTNAME}");
            templateBuilder.AppendLine("{LASTNAME}");
            templateBuilder.AppendLine("{EMAIL}");
            templateBuilder.AppendLine("{USERNAME}");
            templateBuilder.AppendLine("{ACTIVATIONKEY}");
            templateBuilder.AppendLine("{RESETKEY}");
            templateBuilder.AppendLine("{USERID}");
            templateBuilder.AppendLine("{SITENAME}");
            templateBuilder.AppendLine("{SITEURL}");

            StringBuilder expectedContent = new StringBuilder();

            expectedContent.AppendLine(userModel.Firstname);
            expectedContent.AppendLine(userModel.Lastname);
            expectedContent.AppendLine(userModel.NewEmail);
            expectedContent.AppendLine(userModel.NewUsername);
            expectedContent.AppendLine(userModel.ActivationKey);
            expectedContent.AppendLine(userModel.PasswordResetKey);
            expectedContent.AppendLine(userModel.Id.ToString());
            expectedContent.AppendLine(siteSettings.SiteName);
            expectedContent.AppendLine(siteSettings.SiteUrl);

            // Act
            string actualTemplate = emailTemplate.ReplaceTokens(userModel, templateBuilder.ToString());

            // Assert
            Assert.That(actualTemplate, Is.EqualTo(expectedContent.ToString()));
        }
        public void ReplaceTokens_Should_Get_SiteSettings_From_Repository()
        {
            // Issue #229
            // Arrange
            EmailTemplateStub emailTemplate = new EmailTemplateStub(_applicationSettings, _repository, _emailClientMock);
            UserViewModel     userModel     = new UserViewModel();

            SiteSettings expectedSettings = new SiteSettings();

            expectedSettings.SiteName = "MySite";
            expectedSettings.SiteUrl  = "http://www.roadkillwiki.iz.de.biz";
            _repository.SaveSiteSettings(expectedSettings);

            // Act
            emailTemplate.ReplaceTokens(userModel, "not used");
            SiteSettings actualSettings = emailTemplate.GetSiteSettings();

            // Assert
            Assert.That(actualSettings, Is.EqualTo(expectedSettings));
        }