2016-05-06 22:34:33 +00:00
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
using Microsoft.DotNet.Cli;
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
using Xunit;
|
|
|
|
using FluentAssertions;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
{
|
|
|
|
public class GivenDotnetSdk : TestBase
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void VersionCommandDisplaysCorrectVersion()
|
|
|
|
{
|
2017-08-11 15:37:31 +00:00
|
|
|
var versionFilePath = Path.Combine(AppContext.BaseDirectory, "ExpectedSdkVersion.txt");
|
2017-02-14 18:30:28 +00:00
|
|
|
var version = GetVersionFromFile(versionFilePath);
|
|
|
|
|
2016-05-06 22:34:33 +00:00
|
|
|
CommandResult result = new DotnetCommand()
|
|
|
|
.ExecuteWithCapturedOutput("--version");
|
|
|
|
|
|
|
|
result.Should().Pass();
|
2017-02-14 18:30:28 +00:00
|
|
|
result.StdOut.Trim().Should().Be(version);
|
|
|
|
}
|
|
|
|
|
|
|
|
private string GetVersionFromFile(string versionFilePath)
|
|
|
|
{
|
|
|
|
using (var reader = new StreamReader(File.OpenRead(versionFilePath)))
|
|
|
|
{
|
|
|
|
return reader.ReadLine();
|
|
|
|
}
|
|
|
|
}
|
2016-05-06 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|