mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 11:58:39 +08:00
Updating obsolete code due to NUnit upgrade
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Orchard.Azure.Tests {
|
||||
protected abstract void OnInit();
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void FixtureSetup() {
|
||||
if (!Process.GetProcessesByName("AzureStorageEmulator").Any()) {
|
||||
var azureSDKPath = ConfigurationManager.AppSettings["AzureSDK"];
|
||||
@@ -43,7 +43,7 @@ namespace Orchard.Azure.Tests {
|
||||
OnInit();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void FixtureTearDown() {
|
||||
if (_storageEmulator != null)
|
||||
_storageEmulator.Close();
|
||||
|
||||
@@ -85,9 +85,9 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
|
||||
Assert.That(ShellSettingsManager.LoadSettings().Count(), Is.EqualTo(2));
|
||||
|
||||
foo = ShellSettingsManager.LoadSettings().Where(s => s.Name == "Foo").Single();
|
||||
Assert.That(foo.Name, Is.StringContaining("Foo"));
|
||||
Assert.That(foo.DataProvider, Is.StringContaining("Bar"));
|
||||
Assert.That(foo.DataConnectionString, Is.StringContaining("Quux"));
|
||||
Assert.That(foo.Name, Does.Contain("Foo"));
|
||||
Assert.That(foo.DataProvider, Does.Contain("Bar"));
|
||||
Assert.That(foo.DataConnectionString, Does.Contain("Quux"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
|
||||
private IContainer _container;
|
||||
private ITransactionManager _transactionManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
_databaseFileName = Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
@@ -77,7 +77,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
|
||||
_session.Dispose();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
File.Delete(_databaseFileName);
|
||||
}
|
||||
|
||||
@@ -382,12 +382,12 @@ namespace Orchard.Specs.Bindings {
|
||||
|
||||
[Then(@"the content type should be ""(.*)""")]
|
||||
public void ThenTheContentTypeShouldBe(string contentType) {
|
||||
Assert.That(Details.ResponseHeaders["Content-Type"], Is.StringMatching(contentType));
|
||||
Assert.That(Details.ResponseHeaders["Content-Type"], Does.Match(contentType));
|
||||
}
|
||||
|
||||
[Then(@"I should see ""(.*)""")]
|
||||
public void ThenIShouldSee(string text) {
|
||||
Assert.That(Details.ResponseText, Is.StringMatching(text));
|
||||
Assert.That(Details.ResponseText, Does.Match(text));
|
||||
}
|
||||
|
||||
[Then(@"I should not see ""(.*)""")]
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Orchard.Tests.Modules.CodeGeneration.Commands {
|
||||
codeGenerationCommands.Context = new CommandContext { Output = textWriterOutput };
|
||||
codeGenerationCommands.CreateDataMigration("feature");
|
||||
|
||||
Assert.That(textWriterOutput.ToString(), Is.StringContaining("Creating data migration failed"));
|
||||
Assert.That(textWriterOutput.ToString(), Does.Contain("Creating data migration failed"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,11 @@ namespace Orchard.Tests.Modules {
|
||||
protected StubClock _clock;
|
||||
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TearDownFixture() {
|
||||
File.Delete(_databaseFilePath);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Orchard.Tests.Modules.Indexing {
|
||||
private const string IndexName = "Search";
|
||||
private readonly string _basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Orchard.Tests.Modules.Indexing {
|
||||
private ShellSettings _shellSettings;
|
||||
private readonly string _basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Orchard.Tests.Modules.Indexing {
|
||||
private ShellSettings _shellSettings;
|
||||
private readonly string _basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Orchard.Tests.Modules.Migrations {
|
||||
private readonly Path _tempFixtureFolderName = Path.Get(System.IO.Path.GetTempPath()).Combine("Orchard.Tests.Modules.Migrations");
|
||||
private Path _tempFolderName;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void CreateDb() {
|
||||
var types = new[] {
|
||||
typeof(BlogRecord),
|
||||
@@ -111,7 +111,7 @@ Features:
|
||||
");
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Term() {
|
||||
try { _tempFixtureFolderName.Delete(true); }
|
||||
catch { }
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Modules.Packaging.Services {
|
||||
Directory.CreateDirectory(_basePath);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Orchard.Tests.Modules.Packaging.Services {
|
||||
_container = builder.Build();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Modules.Packaging.Services {
|
||||
Directory.CreateDirectory(_basePath);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
private ISession _session;
|
||||
private IFeatureManager _featureManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(databaseFileName,
|
||||
@@ -65,7 +65,7 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
typeof(ContentTypeRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() { }
|
||||
|
||||
[SetUp]
|
||||
@@ -138,7 +138,7 @@ namespace Orchard.Tests.Modules.Themes.Services {
|
||||
try {
|
||||
_siteThemeService.SetSiteTheme("ThemeFourBasedOnFive");
|
||||
} catch (InvalidOperationException ex) {
|
||||
Assert.That(ex.Message, Is.StringMatching("ThemeFiveBasedOnFour"));
|
||||
Assert.That(ex.Message, Does.Match("ThemeFiveBasedOnFour"));
|
||||
}
|
||||
var siteTheme = _siteThemeService.GetSiteTheme();
|
||||
Assert.That(siteTheme.Name, Is.EqualTo("ThemeOne"));
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
private StubClock _clock;
|
||||
private Mock<WorkContext> _workContext;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
@@ -63,7 +63,7 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
typeof(ContentTypePartDefinitionRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
private CultureInfo _currentCulture;
|
||||
private Mock<WorkContext> _workContext;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
_currentCulture = Thread.CurrentThread.CurrentCulture;
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
@@ -68,7 +68,7 @@ namespace Orchard.Tests.Modules.Users.Services
|
||||
typeof(ContentTypePartDefinitionRecord));
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
Thread.CurrentThread.CurrentCulture = _currentCulture;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.Tests.Modules.Warmup {
|
||||
private const string WarmupFolder = "Warmup";
|
||||
private const string TenantFolder = "Sites/Default";
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void Clean() {
|
||||
if (Directory.Exists(_basePath)) {
|
||||
Directory.Delete(_basePath, true);
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Orchard.Tests.Modules.XmlRpc.Controllers {
|
||||
var controller = container.Resolve<LiveWriterController>();
|
||||
var result = controller.Manifest() as ContentResult;
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result.Content, Is.StringContaining("<supportsGetTags>No</supportsGetTags>"));
|
||||
Assert.That(result.Content, Is.StringContaining("<keywordsAsTags>Yes</keywordsAsTags>"));
|
||||
Assert.That(result.Content, Is.StringContaining("<supportsKeywords>Maybe</supportsKeywords>"));
|
||||
Assert.That(result.Content, Does.Contain("<supportsGetTags>No</supportsGetTags>"));
|
||||
Assert.That(result.Content, Does.Contain("<keywordsAsTags>Yes</keywordsAsTags>"));
|
||||
Assert.That(result.Content, Does.Contain("<supportsKeywords>Maybe</supportsKeywords>"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
using NHibernate;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Tests.ContentManagement.Handlers;
|
||||
using Orchard.Tests.ContentManagement.Records;
|
||||
using Orchard.Tests.ContentManagement.Models;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Tests.ContentManagement.Records;
|
||||
using Orchard.Tests.Stubs;
|
||||
using NHibernate.Impl;
|
||||
using Orchard.UI.PageClass;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Tests.ContentManagement {
|
||||
[TestFixture]
|
||||
@@ -31,7 +30,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private ISession _session;
|
||||
private ITransactionManager _transactionManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
using NHibernate;
|
||||
using NHibernate.Exceptions;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Caching;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
using Orchard.ContentManagement.MetaData.Builders;
|
||||
using Orchard.ContentManagement.MetaData.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.DisplayManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Tests.ContentManagement.Handlers;
|
||||
using Orchard.Tests.ContentManagement.Records;
|
||||
using Orchard.Tests.ContentManagement.Models;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Tests.ContentManagement.Records;
|
||||
using Orchard.Tests.Stubs;
|
||||
using Orchard.UI.PageClass;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private ISession _session;
|
||||
private Mock<IContentDefinitionManager> _contentDefinitionManager;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
@@ -66,7 +66,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
|
||||
builder.RegisterInstance(_contentDefinitionManager.Object);
|
||||
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
|
||||
builder.RegisterInstance(new ShellSettings {Name = ShellSettings.DefaultName, DataProvider = "SqlCe"});
|
||||
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
|
||||
|
||||
builder.RegisterType<AlphaPartHandler>().As<IContentHandler>();
|
||||
builder.RegisterType<BetaPartHandler>().As<IContentHandler>();
|
||||
@@ -78,7 +78,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||
builder.RegisterType<ShapeTableLocator>().As<IShapeTableLocator>();
|
||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||
builder.RegisterInstance(new Mock<IPageClassBuilder>().Object);
|
||||
builder.RegisterInstance(new Mock<IPageClassBuilder>().Object);
|
||||
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
|
||||
|
||||
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
|
||||
@@ -115,9 +115,9 @@ namespace Orchard.Tests.ContentManagement {
|
||||
Assert.That(foo.GetType(), Is.EqualTo(typeof(AlphaPart)));
|
||||
}
|
||||
|
||||
[Test, ExpectedException(typeof(InvalidCastException))]
|
||||
[Test]
|
||||
public void StronglyTypedNewShouldThrowCastExceptionIfNull() {
|
||||
_manager.New<BetaPart>(DefaultAlphaName);
|
||||
Assert.Throws<InvalidCastException>(() => _manager.New<BetaPart>(DefaultAlphaName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -205,7 +205,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
|
||||
_contentDefinitionManager.Setup(contentDefinitionManager => contentDefinitionManager.ListTypeDefinitions())
|
||||
.Returns(new List<ContentTypeDefinition> { alphaType, betaType, gammaType, deltaType });
|
||||
|
||||
|
||||
var types = _manager.GetContentTypeDefinitions();
|
||||
|
||||
// Validate that the expected types were obtained
|
||||
@@ -224,12 +224,15 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_session.Flush();
|
||||
}
|
||||
|
||||
[Test, ExpectedException]
|
||||
[Test]
|
||||
public void StandardStringsShouldNotHaveAStandardSize() {
|
||||
var megaRepository = _container.Resolve<IRepository<MegaRecord>>();
|
||||
var mega = new MegaRecord() { SmallStuff = new string('x', 256) };
|
||||
megaRepository.Create(mega);
|
||||
_session.Flush();
|
||||
|
||||
Assert.Throws<GenericADOException>(() => {
|
||||
var mega = new MegaRecord() { SmallStuff = new string('x', 256) };
|
||||
megaRepository.Create(mega);
|
||||
_session.Flush();
|
||||
});
|
||||
}
|
||||
|
||||
private ContentItemRecord CreateModelRecord(string contentType) {
|
||||
@@ -404,8 +407,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DraftRequiredShouldAlwaysBuildNewVersionFromPublishedIfDraftNotFound()
|
||||
{
|
||||
public void DraftRequiredShouldAlwaysBuildNewVersionFromPublishedIfDraftNotFound() {
|
||||
Trace.WriteLine("gamma1");
|
||||
var gamma1 = _manager.Create(DefaultGammaName, VersionOptions.Published);
|
||||
Trace.WriteLine("flush");
|
||||
@@ -426,8 +428,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
Trace.WriteLine("Restore gamma1 as Latest");
|
||||
var gamma2 = _manager.Get(gamma1.Id, VersionOptions.Published);
|
||||
var publishedVersion = gamma2.Record.Versions.SingleOrDefault(x => x.Published);
|
||||
if (publishedVersion != null)
|
||||
{
|
||||
if (publishedVersion != null) {
|
||||
publishedVersion.Latest = true;
|
||||
}
|
||||
Trace.WriteLine("flush");
|
||||
@@ -452,7 +453,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
_session.Clear();
|
||||
|
||||
Trace.WriteLine("gammaDraft1");
|
||||
var gammaDraft1 = _manager.GetMany<ContentItem>(new [] { gamma1.Id }, VersionOptions.Draft, QueryHints.Empty);
|
||||
var gammaDraft1 = _manager.GetMany<ContentItem>(new[] { gamma1.Id }, VersionOptions.Draft, QueryHints.Empty);
|
||||
Assert.That(gammaDraft1.Count(), Is.EqualTo(0));
|
||||
Trace.WriteLine("flush");
|
||||
_session.Flush();
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Orchard.Tests.ContentManagement {
|
||||
private Mock<IContentManager> _contentManager;
|
||||
|
||||
#region Init
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void TestInit() {
|
||||
_testItemIdentity1 = new ContentIdentity("/ItemId=1");
|
||||
_testItemIdentity2 = new ContentIdentity("/ItemId=2");
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Orchard.Tests.Data {
|
||||
public class RepositoryTests {
|
||||
#region Setup/Teardown
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Tests.Data {
|
||||
_session.Close();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
File.Delete(_databaseFilePath);
|
||||
}
|
||||
@@ -65,10 +65,9 @@ namespace Orchard.Tests.Data {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(InvalidOperationException))]
|
||||
public void GetThatReturnsTwoOrMoreShouldThrowException() {
|
||||
CreateThreeFoos();
|
||||
_fooRepos.Get(f => f.Name == "one" || f.Name == "three");
|
||||
Assert.Throws<InvalidOperationException>(() => _fooRepos.Get(f => f.Name == "one" || f.Name == "three"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -153,7 +152,7 @@ namespace Orchard.Tests.Data {
|
||||
_fooRepos.Create(foo1);
|
||||
|
||||
var foo2 = _fooRepos.Get(foo1.Id);
|
||||
foo2.Name = "blah";
|
||||
foo2.Name = "blah";
|
||||
|
||||
Assert.That(foo1, Is.SameAs(foo2));
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace Orchard.Tests.DataMigration {
|
||||
.DropForeignKey("Address", "FK_User");
|
||||
}
|
||||
|
||||
[Test, ExpectedException]
|
||||
[Test]
|
||||
public void BiggerDataShouldNotFit() {
|
||||
_schemaBuilder
|
||||
.CreateTable("ContentItemRecord", table => table
|
||||
@@ -192,8 +192,8 @@ namespace Orchard.Tests.DataMigration {
|
||||
.ExecuteSql("insert into TEST_ContentItemRecord (Data) values('Hello World')");
|
||||
|
||||
// should throw an exception if trying to write more data
|
||||
_schemaBuilder
|
||||
.ExecuteSql(String.Format("insert into TEST_ContentItemRecord (Data) values('{0}')", new String('x', 256)));
|
||||
Assert.Throws<OrchardException>(() => _schemaBuilder
|
||||
.ExecuteSql(String.Format("insert into TEST_ContentItemRecord (Data) values('{0}')", new String('x', 256))));
|
||||
|
||||
_schemaBuilder
|
||||
.AlterTable("ContentItemRecord", table => table
|
||||
@@ -223,17 +223,18 @@ namespace Orchard.Tests.DataMigration {
|
||||
.ExecuteSql(String.Format("insert into TEST_ContentItemRecord (Data) values('{0}')", new String('x', 2048)));
|
||||
}
|
||||
|
||||
[Test, ExpectedException(typeof(OrchardException))]
|
||||
[Test]
|
||||
public void ChangingSizeWithoutTypeShouldNotBeAllowed() {
|
||||
_schemaBuilder
|
||||
.CreateTable("ContentItemRecord", table => table
|
||||
.Column("Id", DbType.Int32, column => column.PrimaryKey().Identity())
|
||||
.Column("Data", DbType.String, column => column.WithLength(255)));
|
||||
|
||||
_schemaBuilder
|
||||
.AlterTable("ContentItemRecord", table => table
|
||||
.AlterColumn("Data", column => column.WithLength(2048)));
|
||||
|
||||
Assert.Throws<OrchardException>(() =>
|
||||
_schemaBuilder
|
||||
.AlterTable("ContentItemRecord", table => table
|
||||
.AlterColumn("Data", column => column.WithLength(2048)))
|
||||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace Orchard.Tests {
|
||||
protected StubClock _clock;
|
||||
protected ShellSettings _shellSettings;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TearDownFixture() {
|
||||
File.Delete(_databaseFilePath);
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
|
||||
var displayContext = new DisplayContext();
|
||||
var result = shapeDescriptor.Binding(displayContext);
|
||||
var result2 = shapeDescriptor.Binding.Invoke(displayContext);
|
||||
Assert.That(result.ToString(), Is.StringContaining("Simple"));
|
||||
Assert.That(result2.ToString(), Is.StringContaining("Simple"));
|
||||
Assert.That(result.ToString(), Does.Contain("Simple"));
|
||||
Assert.That(result2.ToString(), Does.Contain("Simple"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,8 +76,8 @@ namespace Orchard.Tests.Environment.Blueprint {
|
||||
var result = service.Fetch("Hello");
|
||||
var resultInfo = result.ToDataString();
|
||||
|
||||
Assert.That(descriptorInfo, Is.StringContaining("6655321"));
|
||||
Assert.That(resultInfo, Is.StringContaining("6655321"));
|
||||
Assert.That(descriptorInfo, Does.Contain("6655321"));
|
||||
Assert.That(resultInfo, Does.Contain("6655321"));
|
||||
Assert.That(descriptorInfo, Is.EqualTo(resultInfo));
|
||||
|
||||
}
|
||||
|
||||
@@ -63,9 +63,9 @@ namespace Orchard.Tests.Environment.Configuration {
|
||||
Assert.That(loader.LoadSettings().Count(), Is.EqualTo(2));
|
||||
|
||||
var text = _appDataFolder.ReadFile("Sites\\Foo\\Settings.txt");
|
||||
Assert.That(text, Is.StringContaining("Foo"));
|
||||
Assert.That(text, Is.StringContaining("Bar"));
|
||||
Assert.That(text, Is.StringContaining("Quux"));
|
||||
Assert.That(text, Does.Contain("Foo"));
|
||||
Assert.That(text, Does.Contain("Bar"));
|
||||
Assert.That(text, Does.Contain("Quux"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace Orchard.Tests.Environment.Warmup {
|
||||
|
||||
[Test]
|
||||
public void EncodedUrlsShouldPreserveQueryStrings() {
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Is.StringContaining("bar"));
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Is.StringContaining("baz"));
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Is.StringContaining("foo"));
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Does.Contain("bar"));
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Does.Contain("baz"));
|
||||
Assert.That(WarmupUtility.EncodeUrl("http://www.microsoft.com/foo?bar=baz"), Does.Contain("foo"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,8 @@ namespace Orchard.Tests {
|
||||
private int _x;
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof (ApplicationException), ExpectedMessage = "Boom")]
|
||||
public void ExceptionsCanBeVerified() {
|
||||
throw new ApplicationException("Boom");
|
||||
Assert.Throws<ApplicationException>(() => throw new ApplicationException("Boom"), "Boom");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Orchard.Tests.Localization {
|
||||
private string _databaseFileName;
|
||||
private StubWorkContext _stubWorkContext;
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
_databaseFileName = Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
@@ -69,7 +69,7 @@ namespace Orchard.Tests.Localization {
|
||||
_session.Close();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
File.Delete(_databaseFileName);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Orchard.Tests.Localization {
|
||||
private string _databaseFileName;
|
||||
private const string _testCulture = "fr-CA";
|
||||
|
||||
[TestFixtureSetUp]
|
||||
[OneTimeSetUp]
|
||||
public void InitFixture() {
|
||||
_databaseFileName = Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
@@ -57,7 +57,7 @@ namespace Orchard.Tests.Localization {
|
||||
_session.Close();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
[OneTimeTearDown]
|
||||
public void TermFixture() {
|
||||
File.Delete(_databaseFileName);
|
||||
}
|
||||
|
||||
@@ -245,11 +245,10 @@ namespace Orchard.Tests.Localization {
|
||||
|
||||
[Test]
|
||||
[Description("Date/time parsing throws a FormatException for unparsable date/time strings.")]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void ParseDateTimeTest05() {
|
||||
var container = TestHelpers.InitializeContainer("en-US", null, TimeZoneInfo.Utc);
|
||||
var target = container.Resolve<IDateFormatter>();
|
||||
target.ParseDateTime("BlaBlaBla");
|
||||
Assert.Throws<FormatException>(() => target.ParseDateTime("BlaBlaBla"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -303,11 +302,10 @@ namespace Orchard.Tests.Localization {
|
||||
|
||||
[Test]
|
||||
[Description("Date parsing throws a FormatException for unparsable date strings.")]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void ParseDateTest02() {
|
||||
var container = TestHelpers.InitializeContainer("en-US", null, TimeZoneInfo.Utc);
|
||||
var target = container.Resolve<IDateFormatter>();
|
||||
target.ParseDate("BlaBlaBla");
|
||||
Assert.Throws<FormatException>(() => target.ParseDate("BlaBlaBla"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -363,12 +361,10 @@ namespace Orchard.Tests.Localization {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Description("Time parsing throws a FormatException for unparsable time strings.")]
|
||||
[ExpectedException(typeof(FormatException))]
|
||||
public void ParseTimeTest02() {
|
||||
var container = TestHelpers.InitializeContainer("en-US", null, TimeZoneInfo.Utc);
|
||||
var target = container.Resolve<IDateFormatter>();
|
||||
target.ParseTime("BlaBlaBla");
|
||||
Assert.Throws<FormatException>(() => target.ParseTime("BlaBlaBla"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Autofac;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Mvc.Routes;
|
||||
using Orchard.Tests.Utility;
|
||||
@@ -44,14 +43,15 @@ namespace Orchard.Tests.Mvc {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void SameNameTwiceCausesExplosion() {
|
||||
_routes.MapRoute("foo", "{controller}");
|
||||
|
||||
var publisher = _container.Resolve<IRoutePublisher>();
|
||||
publisher.Publish(new[] { Desc("yarg", "bar"), Desc("yarg", "quux") });
|
||||
|
||||
Assert.That(_routes.Count(), Is.EqualTo(2));
|
||||
Assert.Throws<ArgumentException>(() => {
|
||||
publisher.Publish(new[] { Desc("yarg", "bar"), Desc("yarg", "quux") });
|
||||
Assert.That(_routes.Count(), Is.EqualTo(2));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,9 +67,8 @@ namespace Orchard.Tests.Storage {
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void GetFileThatDoesNotExistShouldThrow() {
|
||||
_storageProvider.GetFile("notexisting");
|
||||
Assert.Throws<ArgumentException>((() => _storageProvider.GetFile("notexisting")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -9,27 +9,27 @@ namespace Orchard.Tests.Utility.Extensions {
|
||||
[Test]
|
||||
public void CamelFriendly_CamelCasedStringMadeFriendly() {
|
||||
const string aCamel = "aCamel";
|
||||
Assert.That(aCamel.CamelFriendly(), Is.StringMatching("a Camel"));
|
||||
Assert.That(aCamel.CamelFriendly(), Does.Match("a Camel"));
|
||||
}
|
||||
[Test]
|
||||
public void CamelFriendly_PascalCasedStringMadeFriendly() {
|
||||
const string aCamel = "ACamel";
|
||||
Assert.That(aCamel.CamelFriendly(), Is.StringMatching("A Camel"));
|
||||
Assert.That(aCamel.CamelFriendly(), Does.Match("A Camel"));
|
||||
}
|
||||
[Test]
|
||||
public void CamelFriendly_LowerCasedStringMadeFriendly() {
|
||||
const string aCamel = "acamel";
|
||||
Assert.That(aCamel.CamelFriendly(), Is.StringMatching("acamel"));
|
||||
Assert.That(aCamel.CamelFriendly(), Does.Match("acamel"));
|
||||
}
|
||||
[Test]
|
||||
public void CamelFriendly_EmptyStringReturnsEmptyString() {
|
||||
const string aCamel = "";
|
||||
Assert.That(aCamel.CamelFriendly(), Is.StringMatching(""));
|
||||
Assert.That(aCamel.CamelFriendly(), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void CamelFriendly_NullValueReturnsEmptyString() {
|
||||
const string aCamel = null;
|
||||
Assert.That(aCamel.CamelFriendly(), Is.StringMatching(""));
|
||||
Assert.That(aCamel.CamelFriendly(), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -52,90 +52,90 @@ namespace Orchard.Tests.Utility.Extensions {
|
||||
[Test]
|
||||
public void Ellipsize_LongStringTruncatedToNearestWord() {
|
||||
const string toEllipsize = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(toEllipsize.Ellipsize(46), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur\u00A0\u2026"));
|
||||
Assert.That(toEllipsize.Ellipsize(46), Does.Match("Lorem ipsum dolor sit amet, consectetur\u00A0\u2026"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ellipsize_ShortStringReturnedAsSame() {
|
||||
const string toEllipsize = "Lorem ipsum";
|
||||
Assert.That(toEllipsize.Ellipsize(45), Is.StringMatching("Lorem ipsum"));
|
||||
Assert.That(toEllipsize.Ellipsize(45), Does.Match("Lorem ipsum"));
|
||||
}
|
||||
[Test]
|
||||
public void Ellipsize_EmptyStringReturnsEmptyString() {
|
||||
const string toEllipsize = "";
|
||||
Assert.That(toEllipsize.Ellipsize(45), Is.StringMatching(""));
|
||||
Assert.That(toEllipsize.Ellipsize(45), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void Ellipsize_NullValueReturnsEmptyString() {
|
||||
const string toEllipsize = null;
|
||||
Assert.That(toEllipsize.Ellipsize(45), Is.StringMatching(""));
|
||||
Assert.That(toEllipsize.Ellipsize(45), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void Ellipsize_CustomEllipsisStringIsUsed() {
|
||||
const string toEllipsize = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(toEllipsize.Ellipsize(45, "........"), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur........"));
|
||||
Assert.That(toEllipsize.Ellipsize(45, "........"), Does.Match("Lorem ipsum dolor sit amet, consectetur........"));
|
||||
}
|
||||
[Test]
|
||||
public void Ellipsize_WordBoundary() {
|
||||
const string toEllipsize = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(toEllipsize.Ellipsize(43, "..."), Is.StringMatching("Lorem ipsum dolor sit amet, consectet..."));
|
||||
Assert.That(toEllipsize.Ellipsize(43, "...", true), Is.StringMatching("Lorem ipsum dolor sit amet, ..."));
|
||||
Assert.That(toEllipsize.Ellipsize(43, "..."), Does.Match("Lorem ipsum dolor sit amet, consectet..."));
|
||||
Assert.That(toEllipsize.Ellipsize(43, "...", true), Does.Match("Lorem ipsum dolor sit amet, ..."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HtmlClassify_ValidReallySimpleClassNameReturnsSame() {
|
||||
const string toClassify = "someclass";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(toClassify));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(toClassify));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_NumbersAreMaintainedIfNotAtStart() {
|
||||
const string toClassify = "some4class5";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(toClassify));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(toClassify));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_NumbersAreStrippedAtStart() {
|
||||
const string toClassify = "5someClass";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("some-class"));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match("some-class"));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_ValidSimpleClassNameReturnsSame() {
|
||||
const string toClassify = "some-class";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(toClassify));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(toClassify));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_SimpleStringReturnsSimpleClassName() {
|
||||
const string toClassify = "this is something";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("this-is-something"));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match("this-is-something"));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_ValidComplexClassNameReturnsSimpleClassName() {
|
||||
const string toClassify = @"some-class\&some.other.class";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("some-class-some-other-class"));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match("some-class-some-other-class"));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_CompletelyInvalidClassNameReturnsEmptyString() {
|
||||
const string toClassify = @"0_1234_12";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(""));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_LowerCamelCasedStringReturnsLowerHyphenatedClassName() {
|
||||
const string toClassify = "camelCased";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("camel-cased"));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match("camel-cased"));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_PascalCasedStringReturnsLowerHyphenatedClassName() {
|
||||
const string toClassify = "PascalCased";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("pascal-cased"));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match("pascal-cased"));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_EmptyStringReturnsEmptyString() {
|
||||
const string toClassify = "";
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(""));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void HtmlClassify_NullValueReturnsEmptyString() {
|
||||
const string toClassify = null;
|
||||
Assert.That(toClassify.HtmlClassify(), Is.StringMatching(""));
|
||||
Assert.That(toClassify.HtmlClassify(), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -163,67 +163,67 @@ namespace Orchard.Tests.Utility.Extensions {
|
||||
[Test]
|
||||
public void RemoveTags_StringWithNoTagsReturnsSame() {
|
||||
const string fullOfTags = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(fullOfTags.RemoveTags(), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam."));
|
||||
Assert.That(fullOfTags.RemoveTags(), Does.Match("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam."));
|
||||
}
|
||||
[Test]
|
||||
public void RemoveTags_SimpleWellFormedTagsAreRemoved() {
|
||||
const string fullOfTags = @"<p><em>Lorem ipsum</em> dolor sit amet, consectetur <a href=""#"">adipiscing</a> elit. Maecenas sed purus quis purus orci aliquam.</p>";
|
||||
Assert.That(fullOfTags.RemoveTags(), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam."));
|
||||
Assert.That(fullOfTags.RemoveTags(), Does.Match("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed purus quis purus orci aliquam."));
|
||||
}
|
||||
[Test]
|
||||
public void RemoveTags_EmptyStringReturnsEmptyString() {
|
||||
const string fullOfTags = "";
|
||||
Assert.That(fullOfTags.RemoveTags(), Is.StringMatching(""));
|
||||
Assert.That(fullOfTags.RemoveTags(), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void RemoveTags_NullValueReturnsEmptyString() {
|
||||
const string fullOfTags = null;
|
||||
Assert.That(fullOfTags.RemoveTags(), Is.StringMatching(""));
|
||||
Assert.That(fullOfTags.RemoveTags(), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReplaceNewLinesWith_ReplaceCRLFWithHtmlBR() {
|
||||
const string lotsOfLineFeeds = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMaecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />Maecenas sed purus quis purus orci aliquam."));
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Does.Match("Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />Maecenas sed purus quis purus orci aliquam."));
|
||||
}
|
||||
[Test]
|
||||
public void ReplaceNewLinesWith_ReplaceCRLFWithHtmlPsAndCRLF() {
|
||||
const string lotsOfLineFeeds = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMaecenas sed purus quis purus orci aliquam.";
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith(@"</p>{0}<p>"), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>\r\n<p>Maecenas sed purus quis purus orci aliquam."));
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith(@"</p>{0}<p>"), Does.Match("Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>\r\n<p>Maecenas sed purus quis purus orci aliquam."));
|
||||
}
|
||||
[Test]
|
||||
public void ReplaceNewLinesWith_EmptyStringReturnsEmptyString() {
|
||||
const string lotsOfLineFeeds = "";
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching(""));
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Does.Match(""));
|
||||
}
|
||||
[Test]
|
||||
public void ReplaceNewLinesWith_NullValueReturnsEmptyString() {
|
||||
const string lotsOfLineFeeds = null;
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching(""));
|
||||
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StripShouldRemoveStart() {
|
||||
Assert.That("abc".Strip('a'), Is.StringMatching("bc"));
|
||||
Assert.That("abc".Strip("ab".ToCharArray()), Is.StringMatching("c"));
|
||||
Assert.That("abc".Strip('a'), Does.Match("bc"));
|
||||
Assert.That("abc".Strip("ab".ToCharArray()), Does.Match("c"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StripShouldRemoveInside() {
|
||||
Assert.That("abc".Strip('b'), Is.StringMatching("ac"));
|
||||
Assert.That("abc".Strip("abc".ToCharArray()), Is.StringMatching(""));
|
||||
Assert.That("abc".Strip('b'), Does.Match("ac"));
|
||||
Assert.That("abc".Strip("abc".ToCharArray()), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StripShouldRemoveEnd() {
|
||||
Assert.That("abc".Strip('c'), Is.StringMatching("ab"));
|
||||
Assert.That("abc".Strip("bc".ToCharArray()), Is.StringMatching("a"));
|
||||
Assert.That("abc".Strip('c'), Does.Match("ab"));
|
||||
Assert.That("abc".Strip("bc".ToCharArray()), Does.Match("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void StripShouldReturnIfEmpty() {
|
||||
Assert.That("".Strip('a'), Is.StringMatching(""));
|
||||
Assert.That("a".Strip("".ToCharArray()), Is.StringMatching("a"));
|
||||
Assert.That("".Strip('a'), Does.Match(""));
|
||||
Assert.That("a".Strip("".ToCharArray()), Does.Match("a"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -272,15 +272,15 @@ namespace Orchard.Tests.Utility.Extensions {
|
||||
|
||||
[Test]
|
||||
public void TranslateShouldReturnSource() {
|
||||
Assert.That("a".Translate("".ToCharArray(), "".ToCharArray()), Is.StringMatching(""));
|
||||
Assert.That("".Translate("abc".ToCharArray(), "abc".ToCharArray()), Is.StringMatching(""));
|
||||
Assert.That("a".Translate("".ToCharArray(), "".ToCharArray()), Does.Match(""));
|
||||
Assert.That("".Translate("abc".ToCharArray(), "abc".ToCharArray()), Does.Match(""));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TranslateShouldReplaceChars() {
|
||||
Assert.That("abc".Translate("a".ToCharArray(), "d".ToCharArray()), Is.StringMatching("dbc"));
|
||||
Assert.That("abc".Translate("d".ToCharArray(), "d".ToCharArray()), Is.StringMatching("abc"));
|
||||
Assert.That("abc".Translate("abc".ToCharArray(), "def".ToCharArray()), Is.StringMatching("def"));
|
||||
Assert.That("abc".Translate("a".ToCharArray(), "d".ToCharArray()), Does.Match("dbc"));
|
||||
Assert.That("abc".Translate("d".ToCharArray(), "d".ToCharArray()), Does.Match("abc"));
|
||||
Assert.That("abc".Translate("abc".ToCharArray(), "def".ToCharArray()), Does.Match("def"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user