Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Change ViewLocalizerTest to use ExecutingFilePath to determine ba…
Browse files Browse the repository at this point in the history
…se name

- follow-up to #2767
- resources are now associated with specific page, not the `IView` when the `ViewContext` was created

nit: remove unused `Resources` class
  • Loading branch information
dougbu committed Jan 3, 2016
1 parent 568b061 commit 8547007
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 116 deletions.

This file was deleted.

70 changes: 16 additions & 54 deletions test/Microsoft.AspNet.Mvc.Localization.Test/ViewLocalizerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,8 @@ public void ViewLocalizer_UseIndexer_ReturnsLocalizedHtmlString()
htmlLocalizerFactory.Setup(h => h.Create("TestApplication.example", "TestApplication"))
.Returns(htmlLocalizer.Object);

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(htmlLocalizerFactory.Object, applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -99,13 +94,8 @@ public void ViewLocalizer_UseIndexerWithArguments_ReturnsLocalizedHtmlString()
htmlLocalizerFactory.Setup(
h => h.Create("TestApplication.example", "TestApplication")).Returns(htmlLocalizer.Object);

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(htmlLocalizerFactory.Object, applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -123,13 +113,9 @@ public void ViewLocalizer_GetAllStrings_ReturnsLocalizedString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -148,13 +134,9 @@ public void ViewLocalizer_GetAllStringsIncludeParentCulture_ReturnsLocalizedStri
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -174,13 +156,9 @@ public void ViewLocalizer_GetString_ReturnsLocalizedString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -198,13 +176,9 @@ public void ViewLocalizer_GetStringWithArguments_ReturnsLocalizedString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -222,13 +196,9 @@ public void ViewLocalizer_Html_ReturnsLocalizedHtmlString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -246,13 +216,9 @@ public void ViewLocalizer_HtmlWithArguments_ReturnsLocalizedHtmlString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand All @@ -270,13 +236,9 @@ public void ViewLocalizer_WithCulture_ReturnsLocalizedHtmlString()
var htmlLocalizer = new HtmlLocalizer(stringLocalizer);
var applicationEnvironment = new Mock<IApplicationEnvironment>();
applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication");
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);

var view = new Mock<IView>();
view.Setup(v => v.Path).Returns("example");
var viewContext = new ViewContext();
viewContext.View = view.Object;

var viewContext = new ViewContext { ExecutingFilePath = "example", };
var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object);
viewLocalizer.Contextualize(viewContext);

// Act
Expand Down

0 comments on commit 8547007

Please sign in to comment.