Skip to content

Commit 81f8588

Browse files
committed
Organize unit tests
1 parent 326db0f commit 81f8588

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

test/My.Extensions.Localization.Json.Tests/JsonStringLocalizerFactoryTests.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,45 +111,6 @@ public async Task LocalizerReturnsTranslationFromInnerClass()
111111
var response = await client.GetAsync("/");
112112
}
113113

114-
private void SetupLocalizationOptions(string resourcesPath, ResourcesType resourcesType = ResourcesType.TypeBased)
115-
=> _localizationOptions.Setup(o => o.Value)
116-
.Returns(() => new JsonLocalizationOptions {
117-
ResourcesPath = resourcesPath,
118-
ResourcesType = resourcesType
119-
});
120-
121-
public class InnerClassStartup
122-
{
123-
public void ConfigureServices(IServiceCollection services)
124-
{
125-
services.AddMvc();
126-
services.AddLocalization();
127-
services.AddJsonLocalization(options => options.ResourcesPath = "Resources");
128-
}
129-
130-
public void Configure(IApplicationBuilder app, IStringLocalizer<Model> localizer)
131-
{
132-
var supportedCultures = new[] { "ar", "en" };
133-
app.UseRequestLocalization(options =>
134-
options
135-
.AddSupportedCultures(supportedCultures)
136-
.AddSupportedUICultures(supportedCultures)
137-
.SetDefaultCulture("ar")
138-
);
139-
140-
app.Run(async (context) =>
141-
{
142-
var loc = localizer["Hello"];
143-
await context.Response.WriteAsync(localizer["Hello"]);
144-
});
145-
}
146-
}
147-
148-
public class Model
149-
{
150-
public string Hello { get; set; }
151-
}
152-
153114
[Fact]
154115
public void CreateLocalizerWithType_WithoutRootNamespaceAttribute_UsesAssemblyName()
155116
{
@@ -212,7 +173,7 @@ public void CreateLocalizerWithBasenameAndLocation_WithRootNamespaceAttribute()
212173
// Arrange
213174
var localizerFactory = new JsonStringLocalizerFactory(_localizationOptions.Object, _loggerFactory);
214175
var location = "ResourcesClassLibraryWithAttribute";
215-
var basename = $"MyCustomNamespace.TestModel";
176+
var basename = "MyCustomNamespace.TestModel";
216177

217178
// Act
218179
var localizer = localizerFactory.Create(basename, location);
@@ -221,4 +182,43 @@ public void CreateLocalizerWithBasenameAndLocation_WithRootNamespaceAttribute()
221182
Assert.NotNull(localizer);
222183
Assert.Equal("Bonjour from WithAttribute", localizer["Hello"]);
223184
}
185+
186+
private void SetupLocalizationOptions(string resourcesPath, ResourcesType resourcesType = ResourcesType.TypeBased)
187+
=> _localizationOptions.Setup(o => o.Value)
188+
.Returns(() => new JsonLocalizationOptions {
189+
ResourcesPath = resourcesPath,
190+
ResourcesType = resourcesType
191+
});
192+
193+
public class InnerClassStartup
194+
{
195+
public void ConfigureServices(IServiceCollection services)
196+
{
197+
services.AddMvc();
198+
services.AddLocalization();
199+
services.AddJsonLocalization(options => options.ResourcesPath = "Resources");
200+
}
201+
202+
public void Configure(IApplicationBuilder app, IStringLocalizer<Model> localizer)
203+
{
204+
var supportedCultures = new[] { "ar", "en" };
205+
app.UseRequestLocalization(options =>
206+
options
207+
.AddSupportedCultures(supportedCultures)
208+
.AddSupportedUICultures(supportedCultures)
209+
.SetDefaultCulture("ar")
210+
);
211+
212+
app.Run(async (context) =>
213+
{
214+
var loc = localizer["Hello"];
215+
await context.Response.WriteAsync(localizer["Hello"]);
216+
});
217+
}
218+
}
219+
220+
public class Model
221+
{
222+
public string Hello { get; set; }
223+
}
224224
}

0 commit comments

Comments
 (0)