public async Task DownloadFileAsync_DownloadsRemoteFile_SkipIfContentMatches() { // Arrange var commandBase = new CommandBase(new TestConsole(), new Project(), TestClient); var tempProtoFile = Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "c.proto"); // Act await commandBase.DownloadFileAsync(SourceUrl, tempProtoFile); var lastWriteTime = File.GetLastWriteTime(tempProtoFile); await commandBase.DownloadFileAsync(SourceUrl, tempProtoFile); // Assert Assert.AreEqual(lastWriteTime, File.GetLastWriteTime(tempProtoFile)); File.Delete(tempProtoFile); }
public async Task DownloadFileAsync_DirectoryAsDestination_Throws(string destination) { // Arrange var commandBase = new CommandBase(new TestConsole(), new Project(), TestClient); // Act, Assert await ExceptionAssert.ThrowsAsync <CLIToolException>(() => commandBase.DownloadFileAsync(SourceUrl, destination)).DefaultTimeout(); }
public async Task DownloadFileAsync_DownloadsRemoteFile() { // Arrange var commandBase = new CommandBase(new TestConsole(), new Project(), TestClient); var tempProtoFile = Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "c.proto"); // Act await commandBase.DownloadFileAsync(SourceUrl, tempProtoFile).DefaultTimeout(); // Assert Assert.IsNotEmpty(File.ReadAllText(tempProtoFile)); File.Delete(tempProtoFile); }
public async Task DownloadFileAsync_DownloadsRemoteFile_DoesNotOverwriteForDryrun() { // Arrange var commandBase = new CommandBase(new TestConsole(), new Project(), TestClient); var tempProtoFile = Path.Combine(Directory.GetCurrentDirectory(), "TestAssets", "EmptyProject", "Proto", "c.proto"); // Act File.WriteAllText(tempProtoFile, "NonEquivalent Content"); await commandBase.DownloadFileAsync(SourceUrl, tempProtoFile, true); // Assert Assert.AreEqual("NonEquivalent Content", File.ReadAllText(tempProtoFile)); File.Delete(tempProtoFile); }