diff --git a/src/Microsoft.AspNet.Mvc.Localization/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Localization/Properties/Resources.Designer.cs deleted file mode 100644 index 875f4c8249..0000000000 --- a/src/Microsoft.AspNet.Mvc.Localization/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -namespace Microsoft.AspNet.Mvc.Localization -{ - using System.Globalization; - using System.Reflection; - using System.Resources; - - internal static class Resources - { - private static readonly ResourceManager _resourceManager - = new ResourceManager("Microsoft.AspNet.Mvc.Localization.Resources", typeof(Resources).GetTypeInfo().Assembly); - - /// - /// Must call CreateStringLocalizer method before using this property. - /// - internal static string NullStringLocalizer - { - get { return GetString("NullStringLocalizer"); } - } - - /// - /// Must call CreateStringLocalizer method before using this property. - /// - internal static string FormatNullStringLocalizer() - { - return GetString("NullStringLocalizer"); - } - - /// - /// IStringLocalizerFactory is null. Must call other constructor overload to use this property. - /// - internal static string NullStringLocalizerFactory - { - get { return GetString("NullStringLocalizerFactory"); } - } - - /// - /// IStringLocalizerFactory is null. Must call other constructor overload to use this property. - /// - internal static string FormatNullStringLocalizerFactory() - { - return GetString("NullStringLocalizerFactory"); - } - - private static string GetString(string name, params string[] formatterNames) - { - var value = _resourceManager.GetString(name); - - System.Diagnostics.Debug.Assert(value != null); - - if (formatterNames != null) - { - for (var i = 0; i < formatterNames.Length; i++) - { - value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}"); - } - } - - return value; - } - } -} diff --git a/test/Microsoft.AspNet.Mvc.Localization.Test/ViewLocalizerTest.cs b/test/Microsoft.AspNet.Mvc.Localization.Test/ViewLocalizerTest.cs index 8e60cb3111..a95b7cf409 100644 --- a/test/Microsoft.AspNet.Mvc.Localization.Test/ViewLocalizerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Localization.Test/ViewLocalizerTest.cs @@ -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(); - view.Setup(v => v.Path).Returns("example"); - var viewContext = new ViewContext(); - viewContext.View = view.Object; - viewLocalizer.Contextualize(viewContext); // Act @@ -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(); - view.Setup(v => v.Path).Returns("example"); - var viewContext = new ViewContext(); - viewContext.View = view.Object; - viewLocalizer.Contextualize(viewContext); // Act @@ -123,13 +113,9 @@ public void ViewLocalizer_GetAllStrings_ReturnsLocalizedString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -148,13 +134,9 @@ public void ViewLocalizer_GetAllStringsIncludeParentCulture_ReturnsLocalizedStri var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -174,13 +156,9 @@ public void ViewLocalizer_GetString_ReturnsLocalizedString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -198,13 +176,9 @@ public void ViewLocalizer_GetStringWithArguments_ReturnsLocalizedString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -222,13 +196,9 @@ public void ViewLocalizer_Html_ReturnsLocalizedHtmlString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -246,13 +216,9 @@ public void ViewLocalizer_HtmlWithArguments_ReturnsLocalizedHtmlString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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 @@ -270,13 +236,9 @@ public void ViewLocalizer_WithCulture_ReturnsLocalizedHtmlString() var htmlLocalizer = new HtmlLocalizer(stringLocalizer); var applicationEnvironment = new Mock(); applicationEnvironment.Setup(a => a.ApplicationName).Returns("TestApplication"); - var viewLocalizer = new ViewLocalizer(new TestHtmlLocalizerFactory(), applicationEnvironment.Object); - - var view = new Mock(); - 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