dotnet-installer/test/Microsoft.DotNet.ToolPackage.Tests/ToolConfigurationDeserializerTests.cs
William Lee 55f62d9d64
Add install tool command (#8132)
* compose all the parts

* Fix on obtain and shim maker for better end to end experience
  * Fix error when there is space in the middle of path of nuget config
  * Fix path in profile.d is the tmp home path during install
  * better handle of ~home
  * remove profile.d file in uninstall script
  * Fix test since it looks up current directory
  * folder structure inside nupkg to tools/TFM/RID/mytool.dll
  * Add check for config file existence
  * Rename name space to Microsoft.DotNet.ShellShim
  * Rename name space to Microsoft.DotNet.ToolPackage
2017-12-04 14:13:24 -08:00

52 lines
1.8 KiB
C#

// 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.Collections.Generic;
using System.IO;
using System.Linq;
using FluentAssertions;
using NuGet.Protocol.Core.Types;
using Xunit;
namespace Microsoft.DotNet.ToolPackage.Tests
{
public class ToolConfigurationDeserializerTests
{
[Fact]
public void GivenXmlPathItShouldGetToolConfiguration()
{
ToolConfiguration toolConfiguration = ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsGolden.xml");
toolConfiguration.CommandName.Should().Be("sayhello");
toolConfiguration.ToolAssemblyEntryPoint.Should().Be("console.dll");
}
[Fact]
public void GivenMalformedPathItThrows()
{
Action a = () => ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMalformed.xml");
a.ShouldThrow<ToolConfigurationException>()
.And.Message.Should()
.Contain("The tool's settings file is invalid xml");
}
[Fact]
public void GivenMissingContentItThrows()
{
Action a = () => ToolConfigurationDeserializer.Deserialize("DotnetToolSettingsMissing.xml");
a.ShouldThrow<ToolConfigurationException>()
.And.Message.Should()
.Contain("The tool's settings file contains error");
}
[Fact]
public void GivenInvalidCharAsFileNameItThrows()
{
Action a = () => new ToolConfiguration("na\0me", "my.dll");
a.ShouldThrow<ArgumentException>()
.And.Message.Should()
.Contain("Contains one or more invalid characters");
}
}
}