1 //
2 // Copyright (c) 2010-2018 Antmicro
3 // Copyright (c) 2011-2015 Realtime Embedded
4 //
5 // This file is licensed under the MIT License.
6 // Full license text is available in 'licenses/MIT.txt'.
7 //
8 using System;
9 using NUnit.Framework;
10 using Antmicro.Renode.UserInterface;
11 using Antmicro.Renode.Utilities;
12 using Antmicro.Renode.UserInterface.Commands;
13 
14 namespace Antmicro.Renode.MonitorTests
15 {
16     [TestFixture]
17     public class FeaturesTests
18     {
19         [Test]
AutoLoadCommandTest()20         public void AutoLoadCommandTest()
21         {
22             var commandInteraction = new CommandInteractionEater();
23             var commandInstance = new TestCommand(monitor);
24             monitor.Parse("help", commandInteraction);
25             var contents = commandInteraction.GetContents();
26             Assert.IsTrue(contents.Contains(commandInstance.Description));
27         }
28 
29         [Test]
ShouldHandleNewExtensionsFromLoadedAssembly()30         public void ShouldHandleNewExtensionsFromLoadedAssembly()
31         {
32             var commandInteraction = new CommandInteractionEater();
33             var file = GetType().Assembly.FromResourceToTemporaryFile("MockExtension.cs");
34             monitor.Parse("emulation GetSeed", commandInteraction);
35             monitor.Parse($"i @{file}", commandInteraction);
36             monitor.Parse("emulation GetMockString", commandInteraction);
37             var contentsAfter = commandInteraction.GetContents();
38             Assert.IsTrue(contentsAfter.Contains("this is an extension"));
39         }
40 
41         [SetUp]
SetUp()42         public void SetUp()
43         {
44             monitor = new Monitor();
45         }
46 
47         private Monitor monitor;
48     }
49 
50     public class TestCommand : AutoLoadCommand
51     {
TestCommand(Monitor monitor)52         public TestCommand(Monitor monitor):base(monitor, "featuresTests.TestCommand", "is just a test command.")
53         {
54         }
55     }
56 }
57 
58