Skip to content

Commit

Permalink
Make sure --filedeployment is counted as a valid operation (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBZA authored Feb 24, 2025
1 parent 1b35aa1 commit 716b217
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions nanoFirmwareFlasher.Tests/FileDeploymentTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nanoFirmwareFlasher.Tests.Helpers;
using nanoFramework.Tools.FirmwareFlasher;

namespace nanoFirmwareFlasher.Tests
{
/// <summary>
/// Verify that the options to nanoff are passed correctly to the low-level classes.
/// This cannot be done for the update of firmware, at least not for ESP32, as that
/// requires a connection to a real device.
/// </summary>
[TestClass]
[TestCategory("File deployment")]
[DoNotParallelize] // because of static variables in the programs
public sealed class FileDeploymentTests
{
public TestContext TestContext { get; set; } = null!;

[TestMethod]
public void FileDeployment_Recognizes_ValidOperation()
{
#region Setup
using var output = new OutputWriterHelper();
string testDirectory = TestDirectoryHelper.GetTestDirectory(TestContext);
string deployJsonPath = Path.Combine(testDirectory, "deploy.json");

File.WriteAllText(deployJsonPath, @"{
""serialport"":""COM3"",
""files"": [{
""DestinationFilePath"": ""I:\\deploy.json"",
""SourceFilePath"": """ + deployJsonPath.Replace("\\", "\\\\") + @"""
}]
}");
#endregion

#region Deploy content files
int actual = Program.Main(["--filedeployment", deployJsonPath])
.GetAwaiter().GetResult();

Assert.IsFalse(output.Output.Contains("No operation was performed with the options supplied."));

#endregion
}
}
}
1 change: 1 addition & 0 deletions nanoFirmwareFlasher.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
try
{
_exitCode = await deploy.DeployAsync();
operationPerformed = true;
}
catch (Exception ex)
{
Expand Down

0 comments on commit 716b217

Please sign in to comment.