Adding functional tests for @namespace
This commit is contained in:
parent
3eae7cc393
commit
ed3aa4d918
|
|
@ -1,2 +1,2 @@
|
|||
@using MvcSandbox
|
||||
@namespace MvcSandbox.Pages
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@page
|
||||
@(GetType().Namespace)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@page
|
||||
@(GetType().Namespace)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
@page
|
||||
@namespace Override
|
||||
@(GetType().Namespace)
|
||||
|
|
@ -0,0 +1 @@
|
|||
@namespace CustomNamespace
|
||||
|
|
@ -0,0 +1 @@
|
|||
@namespace RazorPagesWebSite.Pages
|
||||
Loading…
Reference in New Issue