Ejemplo n.º 1
0
        public async Task Refresh_RefreshesReferences(bool dryRun)
        {
            // Arrange
            var currentDir  = Directory.GetCurrentDirectory();
            var tempDir     = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
            var testConsole = new TestConsole();

            new DirectoryInfo(Path.Combine(currentDir, "TestAssets", "ProjectWithReference")).CopyTo(tempDir);

            // Act
            Directory.SetCurrentDirectory(tempDir);
            var command = new RefreshCommand(testConsole, CreateClient());
            await command.RefreshAsync(dryRun, new string[0]);

            // Assert
            Assert.AreEqual(string.Format(CoreStrings.LogDownload, "Proto/a.proto", SourceUrl), testConsole.Out.ToString() !.TrimEnd());
            Assert.AreEqual(dryRun, string.IsNullOrEmpty(File.ReadAllText(Path.Combine(command.Project.DirectoryPath, "Proto", "a.proto"))));

            // Cleanup
            Directory.SetCurrentDirectory(currentDir);
            Directory.Delete(tempDir, true);
        }