From b74ea5d74e96ae87e3e50cd604a22baf10fed3ba Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 27 Oct 2016 08:48:52 -0700 Subject: [PATCH] Fix failing tests --- .../DefaultRazorSyntaxTreePhaseTest.cs | 8 ++++--- .../RazorEngineTest.cs | 22 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultRazorSyntaxTreePhaseTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultRazorSyntaxTreePhaseTest.cs index 91ae926372..1af17353f9 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultRazorSyntaxTreePhaseTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/DefaultRazorSyntaxTreePhaseTest.cs @@ -55,7 +55,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution public void Execute_ExecutesPhasesInOrder() { // Arrange - var codeDocument = TestRazorCodeDocument.CreateEmpty(); // We're going to set up mocks to simulate a sequence of passes. We don't care about @@ -63,13 +62,16 @@ namespace Microsoft.AspNetCore.Razor.Evolution var originalSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); var firstPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); var secondPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); + codeDocument.SetSyntaxTree(originalSyntaxTree); var firstPass = new Mock(MockBehavior.Strict); firstPass.SetupGet(m => m.Order).Returns(0); + firstPass.SetupProperty(m => m.Engine); firstPass.Setup(m => m.Execute(codeDocument, originalSyntaxTree)).Returns(firstPassSyntaxTree); var secondPass = new Mock(MockBehavior.Strict); - secondPass.SetupGet(m => m.Order).Returns(0); + secondPass.SetupGet(m => m.Order).Returns(1); + secondPass.SetupProperty(m => m.Engine); secondPass.Setup(m => m.Execute(codeDocument, firstPassSyntaxTree)).Returns(secondPassSyntaxTree); var phase = new DefaultRazorSyntaxTreePhase(); @@ -78,8 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution { b.Phases.Add(phase); - b.Features.Add(secondPass.Object); b.Features.Add(firstPass.Object); + b.Features.Add(secondPass.Object); }); // Act diff --git a/test/Microsoft.AspNetCore.Razor.Evolution.Test/RazorEngineTest.cs b/test/Microsoft.AspNetCore.Razor.Evolution.Test/RazorEngineTest.cs index 70a207a6a2..5afa17ae3f 100644 --- a/test/Microsoft.AspNetCore.Razor.Evolution.Test/RazorEngineTest.cs +++ b/test/Microsoft.AspNetCore.Razor.Evolution.Test/RazorEngineTest.cs @@ -1,6 +1,7 @@ // 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.Collections.Generic; using System.Linq; using Moq; using Xunit; @@ -18,8 +19,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution // Assert Assert.IsType(engine); - Assert.Empty(engine.Features); - Assert.Empty(engine.Phases); + AssertDefaultFeatures(engine.Features); + AssertDefaultPhases(engine.Phases); } [Fact] @@ -31,8 +32,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution // Assert Assert.IsType(engine); - Assert.Empty(engine.Features); - Assert.Empty(engine.Phases); + AssertDefaultFeatures(engine.Features); + AssertDefaultPhases(engine.Phases); } [Fact] @@ -69,5 +70,18 @@ namespace Microsoft.AspNetCore.Razor.Evolution p => Assert.Same(phases[0], p), p => Assert.Same(phases[1], p)); } + + private static void AssertDefaultFeatures(IEnumerable features) + { + Assert.Empty(features); + } + + private static void AssertDefaultPhases(IReadOnlyList features) + { + Assert.Collection( + features, + f => Assert.IsType(f), + f => Assert.IsType(f)); + } } }