public void ViewLocationFormats_ContainsExpectedLocations()
    {
        // Arrange
        var services      = new ServiceCollection().AddOptions();
        var viewLocations = new[]
        {
            "/MvcViews/{1}/{0}.cshtml",
            "/MvcViews/Shared/{0}.cshtml"
        };
        var builder = new MvcBuilder(services, new ApplicationPartManager());

        builder.AddRazorOptions(options =>
        {
            options.ViewLocationFormats.Clear();

            foreach (var location in viewLocations)
            {
                options.ViewLocationFormats.Add(location);
            }
        });
        var serviceProvider = services.BuildServiceProvider();
        var accessor        = serviceProvider.GetRequiredService <IOptions <RazorViewEngineOptions> >();

        // Act
        var formats = accessor.Value.ViewLocationFormats;

        // Assert
        Assert.Equal(viewLocations, formats, StringComparer.Ordinal);
    }
        public void AddRazorOptions_ConfiguresOptionsProperly()
        {
            // Arrange
            var services     = new ServiceCollection().AddOptions();
            var fileProvider = new TestFileProvider();

            // Act
            var builder = new MvcBuilder(services);

            builder.AddRazorOptions(options =>
            {
                options.FileProvider = fileProvider;
            });
            var serviceProvider = services.BuildServiceProvider();

            // Assert
            var accessor = serviceProvider.GetRequiredService <IOptions <RazorViewEngineOptions> >();

            Assert.Same(fileProvider, accessor.Options.FileProvider);
        }
        public void AddRazorOptions_ConfiguresOptionsAsExpected()
        {
            // Arrange
            var services     = new ServiceCollection().AddOptions();
            var fileProvider = new TestFileProvider();

            // Act
            var builder = new MvcBuilder(services, new ApplicationPartManager());

            builder.AddRazorOptions(options =>
            {
                options.FileProviders.Add(fileProvider);
            });
            var serviceProvider = services.BuildServiceProvider();

            // Assert
            var accessor = serviceProvider.GetRequiredService <IOptions <RazorViewEngineOptions> >();

            Assert.Same(fileProvider, accessor.Value.FileProviders[0]);
        }