Fixed up merging and unit test structures so taht BaseWebTest uses BaseDatabaseFactoryTests.

Fixed up Examine unit test issues
This commit is contained in:
Shannon Deminick
2013-02-20 02:50:08 +06:00
parent dddc308167
commit b47f9e87f1
10 changed files with 136 additions and 84 deletions

View File

@@ -85,10 +85,8 @@ namespace Umbraco.Tests.PublishedContent
/// <summary>
/// Setup any resolvers before freezing
/// </summary>
protected override void OnFreezing()
protected override void FreezeResolution()
{
base.OnFreezing();
PublishedContentStoreResolver.Current = new PublishedContentStoreResolver(new DefaultPublishedContentStore());
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
@@ -98,6 +96,8 @@ namespace Umbraco.Tests.PublishedContent
typeof(TinyMcePropertyEditorValueConverter),
typeof(YesNoPropertyEditorValueConverter)
});
base.FreezeResolution();
}
public override void TearDown()

View File

@@ -35,13 +35,14 @@ namespace Umbraco.Tests.PublishedContent
public override void Initialize()
{
base.Initialize();
UmbracoExamineSearcher.DisableInitializationCheck = true;
BaseUmbracoIndexer.DisableInitializationCheck = true;
}
protected override void OnFreezing()
{
base.OnFreezing();
DoInitialization(GetUmbracoContext("/test", 1234));
protected override void FreezeResolution()
{
DoInitialization(GetUmbracoContext("/test", 1234));
base.FreezeResolution();
}
@@ -89,6 +90,8 @@ namespace Umbraco.Tests.PublishedContent
/// </summary>
internal static void DoTearDown()
{
UmbracoExamineSearcher.DisableInitializationCheck = null;
BaseUmbracoIndexer.DisableInitializationCheck = null;
PropertyEditorValueConvertersResolver.Reset();
UmbracoContext.Current = null;
PublishedMediaStoreResolver.Reset();
@@ -117,38 +120,41 @@ namespace Umbraco.Tests.PublishedContent
[Test]
public void Do_Not_Find_In_Recycle_Bin()
{
var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString()));
var indexInit = new IndexInitializer();
var indexer = indexInit.GetUmbracoIndexer(newIndexFolder);
indexer.RebuildIndex();
var searcher = indexInit.GetUmbracoSearcher(newIndexFolder);
var store = new DefaultPublishedMediaStore(searcher);
var ctx = GetUmbracoContext("/test", 1234);
using (var luceneDir = new RAMDirectory())
{
var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir);
indexer.RebuildIndex();
var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir);
var store = new DefaultPublishedMediaStore(searcher);
var ctx = GetUmbracoContext("/test", 1234);
//ensure it is found
var publishedMedia = store.GetDocumentById(ctx, 3113);
Assert.IsNotNull(publishedMedia);
//ensure it is found
var publishedMedia = store.GetDocumentById(ctx, 3113);
Assert.IsNotNull(publishedMedia);
//move item to recycle bin
var newXml = XElement.Parse(@"<node id='3113' version='5b3e46ab-3e37-4cfa-ab70-014234b5bd33' parentID='-21' level='1' writerID='0' nodeType='1032' template='0' sortOrder='2' createDate='2010-05-19T17:32:46' updateDate='2010-05-19T17:32:46' nodeName='Another Umbraco Image' urlName='acnestressscrub' writerName='Administrator' nodeTypeAlias='Image' path='-1,-21,3113'>
//move item to recycle bin
var newXml = XElement.Parse(@"<node id='3113' version='5b3e46ab-3e37-4cfa-ab70-014234b5bd33' parentID='-21' level='1' writerID='0' nodeType='1032' template='0' sortOrder='2' createDate='2010-05-19T17:32:46' updateDate='2010-05-19T17:32:46' nodeName='Another Umbraco Image' urlName='acnestressscrub' writerName='Administrator' nodeTypeAlias='Image' path='-1,-21,3113'>
<data alias='umbracoFile'><![CDATA[/media/1234/blah.pdf]]></data>
<data alias='umbracoWidth'>115</data>
<data alias='umbracoHeight'>268</data>
<data alias='umbracoBytes'>10726</data>
<data alias='umbracoExtension'>jpg</data>
</node>");
indexer.ReIndexNode(newXml, "media");
indexer.ReIndexNode(newXml, "media");
//ensure it still exists in the index (raw examine search)
var criteria = searcher.CreateSearchCriteria();
var filter = criteria.Id(3113);
var found = searcher.Search(filter.Compile());
Assert.IsNotNull(found);
Assert.AreEqual(1, found.TotalItemCount);
//ensure it still exists in the index (raw examine search)
var criteria = searcher.CreateSearchCriteria();
var filter = criteria.Id(3113);
var found = searcher.Search(filter.Compile());
Assert.IsNotNull(found);
Assert.AreEqual(1, found.TotalItemCount);
//ensure it does not show up in the published media store
var recycledMedia = store.GetDocumentById(ctx, 3113);
Assert.IsNull(recycledMedia);
//ensure it does not show up in the published media store
var recycledMedia = store.GetDocumentById(ctx, 3113);
Assert.IsNull(recycledMedia);
}
}
[Test]

View File

@@ -22,11 +22,12 @@ namespace Umbraco.Tests.PublishedContent
base.Initialize();
}
protected override void OnFreezing()
{
protected override void FreezeResolution()
{
var routingCtx = GetRoutingContext("/test", 1234);
UmbracoContext.Current = routingCtx.UmbracoContext;
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(Enumerable.Empty<Type>());
base.FreezeResolution();
}
public override void TearDown()