* Index.aspx: * Title.aspx: * YavscModel.csproj: * BlogEntry.cs: * yavsc.scrollnotif.js: * AccountController.cs: * BlogEntryCollection.cs: refactoring * yavsc.tags.js: Implements a js call to the tag & untag methods * PostActions.ascx: a better html structure * BasePost.cs: refactoring: allows the "PostActions" user control to use a common base object as post reference * NpgsqlBlogProvider.cs: implements the tag methods on db * ResultPages.cs: A multi-pages result meta info when one page only * yavsc.circles.js: * AccountController.cs: code formatting * BlogsController.cs: Untag a post * style.css: yastyle, yet a better one. * BlogsController.cs: View the Title after edition * App.master: * UserPosts.aspx: a nicer html structure * yavsc.js: Fixes notice & dimiss js * Login.aspx: refactoring * Edit.aspx: better html * UserPost.aspx: A promess to be allowed to tag. * Web.csproj: Adds yavsc.tags.js and yavsc.scrollnotifs.js to the project decription. * BlogManager.cs: Makes the blog manager expose of the new `UnTag` method * BlogProvider.cs: introduces a method to `untag` * FindBlogEntryFlags.cs: Find post entry by tag * LocalizedText.resx: * LocalizedText.Designer.cs: new translations: - "Tag" - "Edit" * LocalizedText.fr.resx: * LocalizedText.fr.Designer.cs: nouvelles traductions: - "Tag" - "Edit" * Profile.cs: a nicer stack trace at buggy usage
105 lines
3.3 KiB
C#
105 lines
3.3 KiB
C#
//
|
|
// BlogUnitTest.cs
|
|
//
|
|
// Author:
|
|
// Paul Schneider <paul@pschneider.fr>
|
|
//
|
|
// Copyright (c) 2015 GNU GPL
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Lesser General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
using NUnit.Framework;
|
|
using System;
|
|
using Yavsc.Model.Blogs;
|
|
using Yavsc.Controllers;
|
|
using System.Web.Mvc;
|
|
using System.Web.Security;
|
|
using System.Web.Configuration;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Web.Http;
|
|
|
|
namespace Yavsc
|
|
{
|
|
|
|
[TestFixture ()]
|
|
public class AccountUnitTestCase
|
|
{
|
|
|
|
public string UserName { get; set; }
|
|
public string Email { get; set; }
|
|
public string Password { get; set; }
|
|
|
|
AccountController accountController;
|
|
|
|
public AccountController AccountController {
|
|
get {
|
|
return accountController;
|
|
}
|
|
}
|
|
string defaultMembershipProvider = null;
|
|
[Test]
|
|
public virtual void Init()
|
|
{
|
|
webSource = new XSPWebSource (configurationManager.Address, configurationManager.Port, !root);
|
|
|
|
|
|
var server = new ApplicationServer (webSource, configurationManager.Root) {
|
|
Verbose = configurationManager.Verbose,
|
|
SingleApplication = !root
|
|
};
|
|
string basedir = AppDomain.CurrentDomain.BaseDirectory;
|
|
string curdir = Directory.GetCurrentDirectory ();
|
|
string dummyVirtualPath = "/";
|
|
string physicalPath = @"/home/paul/workspace/totem/web/";
|
|
WebConfigurationFileMap map = new WebConfigurationFileMap ();
|
|
map.VirtualDirectories.Add(dummyVirtualPath, new VirtualDirectoryMapping(physicalPath, true));
|
|
Configuration configuration = WebConfigurationManager.OpenMappedWebConfiguration(map, dummyVirtualPath);
|
|
accountController = new AccountController ();
|
|
string da = (string) configuration.AppSettings.Settings ["DefaultAvatar"].Value;
|
|
MembershipSection s = configuration.GetSection ("system.web/membership") as MembershipSection;
|
|
defaultMembershipProvider = s.DefaultProvider;
|
|
}
|
|
|
|
[Test ()]
|
|
public virtual void Register ()
|
|
{
|
|
ViewResult actionResult = accountController.Register (
|
|
new Yavsc.Model.RolesAndMembers.RegisterViewModel () {
|
|
UserName = UserName, Email = Email,
|
|
Password = "tpwd", ConfirmPassword = Password,
|
|
IsApprouved = true
|
|
},
|
|
"/testreturnurl") as ViewResult;
|
|
Assert.AreSame ("",actionResult.ViewName);
|
|
MembershipUser u = Membership.GetUser (UserName, false);
|
|
Assert.NotNull (u);
|
|
Assert.False (u.IsApproved);
|
|
// TODO : check mail for test,
|
|
// get the validation key from its body,
|
|
// and use the accountController.Validate(username,key)
|
|
u.IsApproved = true;
|
|
Membership.UpdateUser (u);
|
|
Assert.True (u.IsApproved);
|
|
}
|
|
|
|
[TestFixtureTearDown()]
|
|
public virtual void Unregister()
|
|
{
|
|
ViewResult actionResult =
|
|
accountController.Unregister (UserName, true) as ViewResult;
|
|
Assert.AreEqual (actionResult.ViewName, "Index");
|
|
}
|
|
}
|
|
}
|
|
|