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-02-14 18:30:28 +00:00
|
|
|
var versionFilePath = Path.Combine(AppContext.BaseDirectory, ".version");
|
|
|
|
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)))
|
|
|
|
{
|
|
|
|
SkipCommit(reader);
|
|
|
|
return reader.ReadLine();
|
|
|
|
}
|
|
|
|
}
|
2016-05-06 22:34:33 +00:00
|
|
|
|
2017-02-14 18:30:28 +00:00
|
|
|
private void SkipCommit(StreamReader reader)
|
|
|
|
{
|
|
|
|
reader.ReadLine();
|
2016-05-06 22:34:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|