|
| 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 | +} |
0 commit comments