From cdbf89ee570d481f479bf5eb00ae8220c8667457 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 8 Jan 2014 17:08:13 +1100 Subject: [PATCH] Fixes up the unit tests --- src/Umbraco.Core/Properties/AssemblyInfo.cs | 5 ++++- src/Umbraco.Tests/BusinessLogic/ApplicationTest.cs | 3 ++- .../UmbracoServiceMembershipProviderTests.cs | 14 +++++++------- .../Persistence/Repositories/UserRepositoryTest.cs | 5 +++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Core/Properties/AssemblyInfo.cs b/src/Umbraco.Core/Properties/AssemblyInfo.cs index 641fde43a1..bd7d67f6af 100644 --- a/src/Umbraco.Core/Properties/AssemblyInfo.cs +++ b/src/Umbraco.Core/Properties/AssemblyInfo.cs @@ -44,4 +44,7 @@ using System.Security.Permissions; [assembly: InternalsVisibleTo("Concorde.Sync")] [assembly: InternalsVisibleTo("Umbraco.Belle")] [assembly: InternalsVisibleTo("Umbraco.VisualStudio")] -[assembly: InternalsVisibleTo("umbraco.providers")] \ No newline at end of file +[assembly: InternalsVisibleTo("umbraco.providers")] + +//allow this to be mocked in our unit tests +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/Umbraco.Tests/BusinessLogic/ApplicationTest.cs b/src/Umbraco.Tests/BusinessLogic/ApplicationTest.cs index 1bcd405c67..60a316b510 100644 --- a/src/Umbraco.Tests/BusinessLogic/ApplicationTest.cs +++ b/src/Umbraco.Tests/BusinessLogic/ApplicationTest.cs @@ -1,4 +1,5 @@ using NUnit.Framework; +using Umbraco.Tests.TestHelpers; using umbraco.BusinessLogic; using System; using System.Linq; @@ -11,7 +12,7 @@ namespace Umbraco.Tests.BusinessLogic ///to contain all ApplicationTest Unit Tests /// [TestFixture()] - public class ApplicationTest : BaseTest + public class ApplicationTest : BaseDatabaseFactoryTest { /// diff --git a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs index 183e5b0e4f..35092f6bb6 100644 --- a/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs +++ b/src/Umbraco.Tests/Membership/UmbracoServiceMembershipProviderTests.cs @@ -59,7 +59,7 @@ namespace Umbraco.Tests.Membership provider.Initialize("test", new NameValueCollection()); MembershipCreateStatus status; - var user = provider.CreateUser("test", "test", "test", "test@test.com", "test", "test", true, "test", out status); + var user = provider.CreateUser("test", "test", "testtest$1", "test@test.com", "test", "test", true, "test", out status); Assert.IsNull(user); } @@ -75,7 +75,7 @@ namespace Umbraco.Tests.Membership provider.Initialize("test", new NameValueCollection { { "requiresUniqueEmail", "true" } }); MembershipCreateStatus status; - var user = provider.CreateUser("test", "test", "test", "test@test.com", "test", "test", true, "test", out status); + var user = provider.CreateUser("test", "test", "testtest$1", "test@test.com", "test", "test", true, "test", out status); Assert.IsNull(user); } @@ -105,7 +105,7 @@ namespace Umbraco.Tests.Membership MembershipCreateStatus status; - provider.CreateUser("test", "test", "test", "test@test.com", "test", "test", true, "test", out status); + provider.CreateUser("test", "test", "testtest$1", "test@test.com", "test", "test", true, "test", out status); Assert.AreNotEqual("test", createdMember.PasswordAnswer); Assert.AreEqual(provider.EncryptString("test"), createdMember.PasswordAnswer); @@ -137,11 +137,11 @@ namespace Umbraco.Tests.Membership MembershipCreateStatus status; - provider.CreateUser("test", "test", "test", "test@test.com", "test", "test", true, "test", out status); + provider.CreateUser("test", "test", "testtest$1", "test@test.com", "test", "test", true, "test", out status); Assert.AreNotEqual("test", createdMember.Password); var decrypted = provider.DecryptPassword(createdMember.Password); - Assert.AreEqual("test", decrypted); + Assert.AreEqual("testtest$1", decrypted); } [Test] @@ -170,13 +170,13 @@ namespace Umbraco.Tests.Membership MembershipCreateStatus status; - provider.CreateUser("test", "test", "test", "test@test.com", "test", "test", true, "test", out status); + provider.CreateUser("test", "test", "testtest$1", "test@test.com", "test", "test", true, "test", out status); Assert.AreNotEqual("test", createdMember.Password); string salt; var storedPassword = provider.StoredPassword(createdMember.Password, out salt); - var hashedPassword = provider.EncryptOrHashPassword("test", salt); + var hashedPassword = provider.EncryptOrHashPassword("testtest$1", salt); Assert.AreEqual(hashedPassword, storedPassword); } diff --git a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs index 6a4ad7de12..45ae1d4744 100644 --- a/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs +++ b/src/Umbraco.Tests/Persistence/Repositories/UserRepositoryTest.cs @@ -134,7 +134,8 @@ namespace Umbraco.Tests.Persistence.Repositories var resolved = (User)repository.Get((int)user.Id); resolved.Name = "New Name"; - resolved.DefaultPermissions = new[]{"Z", "Y", "X"}; + //the db column is not used, default permissions are taken from the user type's permissions, this is a getter only + //resolved.DefaultPermissions = "ZYX"; resolved.Language = "fr"; resolved.IsApproved = false; resolved.Password = "new"; @@ -153,7 +154,7 @@ namespace Umbraco.Tests.Persistence.Repositories // Assert Assert.That(updatedItem.Id, Is.EqualTo(resolved.Id)); Assert.That(updatedItem.Name, Is.EqualTo(resolved.Name)); - Assert.That(updatedItem.DefaultPermissions, Is.EqualTo(resolved.DefaultPermissions)); + //Assert.That(updatedItem.DefaultPermissions, Is.EqualTo(resolved.DefaultPermissions)); Assert.That(updatedItem.Language, Is.EqualTo(resolved.Language)); Assert.That(updatedItem.IsApproved, Is.EqualTo(resolved.IsApproved)); Assert.That(updatedItem.Password, Is.EqualTo(resolved.Password));