dotnet-installer/test/Microsoft.DotNet.ShellShim.Tests/FakeFile.cs
Peter Huene aab9af71b8
Implement uninstall tool command.
This commit implements the `uninstall tool` command.

The `uninstall tool` command is responsible for uninstalling global tools that
are installed with the `install tool` command.

This commit heavily refactors the ToolPackage and ShellShim namespaces to
better support the operations required for the uninstall command.

Several string resources have been updated to be more informative or to correct
oddly structured sentences.

This commit also fixes `--version` on the install command not supporting ranges
and wildcards.

Fixes #8549.

Issue #8485 is partially fixed by this commit (`--prerelease` is not yet
implemented).
2018-02-19 22:46:16 -08:00

64 lines
1.6 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 Microsoft.Extensions.EnvironmentAbstractions;
namespace Microsoft.DotNet.ShellShim.Tests
{
internal class FakeFile : IFile
{
private Dictionary<string, string> _files;
public FakeFile(Dictionary<string, string> files)
{
_files = files;
}
public bool Exists(string path)
{
return _files.ContainsKey(path);
}
public string ReadAllText(string path)
{
throw new NotImplementedException();
}
public Stream OpenRead(string path)
{
throw new NotImplementedException();
}
public Stream OpenFile(string path, FileMode fileMode, FileAccess fileAccess, FileShare fileShare,
int bufferSize,
FileOptions fileOptions)
{
throw new NotImplementedException();
}
public void CreateEmptyFile(string path)
{
_files.Add(path, String.Empty);
}
public void WriteAllText(string path, string content)
{
_files[path] = content;
}
public void Move(string source, string destination)
{
throw new NotImplementedException();
}
public void Delete(string path)
{
throw new NotImplementedException();
}
public static FakeFile Empty => new FakeFile(new Dictionary<string, string>());
}
}