Adding functional tests for @namespace

This commit is contained in:
Ryan Nowak 2017-04-13 07:55:30 -07:00
parent 3eae7cc393
commit ed3aa4d918
7 changed files with 63 additions and 1 deletions

View File

@ -1,2 +1,2 @@
@using MvcSandbox
@namespace MvcSandbox.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,53 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
{
public class RazorPagesNamespaceTest : IClassFixture<MvcTestFixture<RazorPagesWebSite.Startup>>
{
public RazorPagesNamespaceTest(MvcTestFixture<RazorPagesWebSite.Startup> fixture)
{
Client = fixture.Client;
}
public HttpClient Client { get; }
[Fact]
public async Task Page_DefaultNamespace_IfUnset()
{
// Arrange & Act
var content = await Client.GetStringAsync("http://localhost/DefaultNamespace");
// Assert
Assert.Equal("AspNetCore", content.Trim());
}
[Fact]
public async Task Page_ImportedNamespace_UsedFromViewImports()
{
// Arrange & Act
var content = await Client.GetStringAsync("http://localhost/Pages/Namespace/Nested/Folder");
// Assert
Assert.Equal("CustomNamespace.Nested.Folder", content.Trim());
}
[Fact]
public async Task Page_OverrideNamespace_SetByPage()
{
// Arrange & Act
var content = await Client.GetStringAsync("http://localhost/Pages/Namespace/Nested/Override");
// Assert
Assert.Equal("Override", content.Trim());
}
}
}

View File

@ -0,0 +1,2 @@
@page
@(GetType().Namespace)

View File

@ -0,0 +1,2 @@
@page
@(GetType().Namespace)

View File

@ -0,0 +1,3 @@
@page
@namespace Override
@(GetType().Namespace)

View File

@ -0,0 +1 @@
@namespace CustomNamespace

View File

@ -0,0 +1 @@
@namespace RazorPagesWebSite.Pages