Skip to content

Commit 716b217

Browse files
authored
Make sure --filedeployment is counted as a valid operation (#317)
1 parent 1b35aa1 commit 716b217

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using Microsoft.VisualStudio.TestTools.UnitTesting;
8+
using nanoFirmwareFlasher.Tests.Helpers;
9+
using nanoFramework.Tools.FirmwareFlasher;
10+
11+
namespace nanoFirmwareFlasher.Tests
12+
{
13+
/// <summary>
14+
/// Verify that the options to nanoff are passed correctly to the low-level classes.
15+
/// This cannot be done for the update of firmware, at least not for ESP32, as that
16+
/// requires a connection to a real device.
17+
/// </summary>
18+
[TestClass]
19+
[TestCategory("File deployment")]
20+
[DoNotParallelize] // because of static variables in the programs
21+
public sealed class FileDeploymentTests
22+
{
23+
public TestContext TestContext { get; set; } = null!;
24+
25+
[TestMethod]
26+
public void FileDeployment_Recognizes_ValidOperation()
27+
{
28+
#region Setup
29+
using var output = new OutputWriterHelper();
30+
string testDirectory = TestDirectoryHelper.GetTestDirectory(TestContext);
31+
string deployJsonPath = Path.Combine(testDirectory, "deploy.json");
32+
33+
File.WriteAllText(deployJsonPath, @"{
34+
""serialport"":""COM3"",
35+
""files"": [{
36+
""DestinationFilePath"": ""I:\\deploy.json"",
37+
""SourceFilePath"": """ + deployJsonPath.Replace("\\", "\\\\") + @"""
38+
}]
39+
}");
40+
#endregion
41+
42+
#region Deploy content files
43+
int actual = Program.Main(["--filedeployment", deployJsonPath])
44+
.GetAwaiter().GetResult();
45+
46+
Assert.IsFalse(output.Output.Contains("No operation was performed with the options supplied."));
47+
48+
#endregion
49+
}
50+
}
51+
}

nanoFirmwareFlasher.Tool/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
764764
try
765765
{
766766
_exitCode = await deploy.DeployAsync();
767+
operationPerformed = true;
767768
}
768769
catch (Exception ex)
769770
{

0 commit comments

Comments
 (0)