Пример #1
0
    public void AddLocalizationServices_AddsNeededServices()
    {
        // Arrange
        var collection = new ServiceCollection();

        // Act
        MvcLocalizationServices.AddMvcViewLocalizationServices(
            collection,
            LanguageViewLocationExpanderFormat.Suffix);

        // Assert
        AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(HtmlLocalizerFactory));
        AssertContainsSingle(collection, typeof(IHtmlLocalizer <>), typeof(HtmlLocalizer <>));
        AssertContainsSingle(collection, typeof(IViewLocalizer), typeof(ViewLocalizer));
    }
Пример #2
0
    public void AddCustomLocalizers_BeforeAddLocalizationServices_AddsNeededServices()
    {
        // Arrange
        var collection = new ServiceCollection();

        // Act
        collection.Add(ServiceDescriptor.Singleton(typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory)));
        collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer <>), typeof(TestHtmlLocalizer <>)));
        collection.Add(ServiceDescriptor.Transient(typeof(IViewLocalizer), typeof(TestViewLocalizer)));

        MvcLocalizationServices.AddMvcViewLocalizationServices(
            collection,
            LanguageViewLocationExpanderFormat.Suffix);

        AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory));
        AssertContainsSingle(collection, typeof(IHtmlLocalizer <>), typeof(TestHtmlLocalizer <>));
        AssertContainsSingle(collection, typeof(IViewLocalizer), typeof(TestViewLocalizer));
    }