Fix failing tests

This commit is contained in:
Ryan Nowak 2016-10-27 08:48:52 -07:00 committed by N. Taylor Mullen
parent b341340d1f
commit b74ea5d74e
2 changed files with 23 additions and 7 deletions

View File

@ -55,7 +55,6 @@ namespace Microsoft.AspNetCore.Razor.Evolution
public void Execute_ExecutesPhasesInOrder() public void Execute_ExecutesPhasesInOrder()
{ {
// Arrange // Arrange
var codeDocument = TestRazorCodeDocument.CreateEmpty(); var codeDocument = TestRazorCodeDocument.CreateEmpty();
// We're going to set up mocks to simulate a sequence of passes. We don't care about // 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 originalSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source);
var firstPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); var firstPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source);
var secondPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source); var secondPassSyntaxTree = RazorSyntaxTree.Parse(codeDocument.Source);
codeDocument.SetSyntaxTree(originalSyntaxTree);
var firstPass = new Mock<IRazorSyntaxTreePass>(MockBehavior.Strict); var firstPass = new Mock<IRazorSyntaxTreePass>(MockBehavior.Strict);
firstPass.SetupGet(m => m.Order).Returns(0); firstPass.SetupGet(m => m.Order).Returns(0);
firstPass.SetupProperty(m => m.Engine);
firstPass.Setup(m => m.Execute(codeDocument, originalSyntaxTree)).Returns(firstPassSyntaxTree); firstPass.Setup(m => m.Execute(codeDocument, originalSyntaxTree)).Returns(firstPassSyntaxTree);
var secondPass = new Mock<IRazorSyntaxTreePass>(MockBehavior.Strict); var secondPass = new Mock<IRazorSyntaxTreePass>(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); secondPass.Setup(m => m.Execute(codeDocument, firstPassSyntaxTree)).Returns(secondPassSyntaxTree);
var phase = new DefaultRazorSyntaxTreePhase(); var phase = new DefaultRazorSyntaxTreePhase();
@ -78,8 +80,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
{ {
b.Phases.Add(phase); b.Phases.Add(phase);
b.Features.Add(secondPass.Object);
b.Features.Add(firstPass.Object); b.Features.Add(firstPass.Object);
b.Features.Add(secondPass.Object);
}); });
// Act // Act

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved. // 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. // 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 System.Linq;
using Moq; using Moq;
using Xunit; using Xunit;
@ -18,8 +19,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
// Assert // Assert
Assert.IsType<DefaultRazorEngine>(engine); Assert.IsType<DefaultRazorEngine>(engine);
Assert.Empty(engine.Features); AssertDefaultFeatures(engine.Features);
Assert.Empty(engine.Phases); AssertDefaultPhases(engine.Phases);
} }
[Fact] [Fact]
@ -31,8 +32,8 @@ namespace Microsoft.AspNetCore.Razor.Evolution
// Assert // Assert
Assert.IsType<DefaultRazorEngine>(engine); Assert.IsType<DefaultRazorEngine>(engine);
Assert.Empty(engine.Features); AssertDefaultFeatures(engine.Features);
Assert.Empty(engine.Phases); AssertDefaultPhases(engine.Phases);
} }
[Fact] [Fact]
@ -69,5 +70,18 @@ namespace Microsoft.AspNetCore.Razor.Evolution
p => Assert.Same(phases[0], p), p => Assert.Same(phases[0], p),
p => Assert.Same(phases[1], p)); p => Assert.Same(phases[1], p));
} }
private static void AssertDefaultFeatures(IEnumerable<IRazorEngineFeature> features)
{
Assert.Empty(features);
}
private static void AssertDefaultPhases(IReadOnlyList<IRazorEnginePhase> features)
{
Assert.Collection(
features,
f => Assert.IsType<DefaultRazorParsingPhase>(f),
f => Assert.IsType<DefaultRazorSyntaxTreePhase>(f));
}
} }
} }