Skip to content

Commit 9ce4066

Browse files
author
LoneWandererProductions
committed
commit wip
1 parent 11ca2f0 commit 9ce4066

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

InterpreteTests/FeedbackTests.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
using System.Collections.Generic;
1010
using System.Diagnostics;
11+
using System.Reflection.PortableExecutable;
1112
using Interpreter;
1213
using Microsoft.VisualStudio.TestTools.UnitTesting;
1314

@@ -29,6 +30,25 @@ public sealed class FeedbackTests
2930
/// </summary>
3031
private static OutCommand _outCommand;
3132

33+
/// <summary>
34+
/// For commands that need your feedback
35+
/// </summary>
36+
internal static readonly Dictionary<int, UserFeedback> Feedback = new() { { 1, ReplaceFeedback } };
37+
38+
/// <summary>
39+
/// The replace feedback
40+
/// </summary>
41+
private static readonly UserFeedback ReplaceFeedback = new()
42+
{
43+
Before = true,
44+
Message = "Do you want to commit the following changes?",
45+
Options = new Dictionary<AvailableFeedback, string>
46+
{
47+
{ AvailableFeedback.Yes, "If you want to execute the Command type yes" },
48+
{ AvailableFeedback.No, " If you want to stop executing the Command type no." }
49+
}
50+
};
51+
3252
/// <summary>
3353
/// Feedback and extension test.
3454
/// </summary>
@@ -86,6 +106,64 @@ public void FeedbackExtension()
86106
Trace.WriteLine(_outCommand.ToString());
87107
}
88108

109+
/// <summary>
110+
/// Feedback and extension external test.
111+
/// </summary>
112+
[TestMethod]
113+
public void FeedbackExtensionExternal()
114+
{
115+
// Arrange
116+
var dctCommandOne = new Dictionary<int, InCommand>
117+
{
118+
{ 0, new InCommand { Command = "com1", ParameterCount = 2, Description = "Help com1" } },
119+
{
120+
1,
121+
new InCommand { Command = "com2", ParameterCount = 0, Description = "com2 Command Namespace 1" }
122+
},
123+
{
124+
2,
125+
new InCommand
126+
{
127+
Command = "com3", ParameterCount = 0, Description = "Special case no Parameter"
128+
}
129+
}
130+
};
131+
132+
// Act
133+
var prompt = new Prompt();
134+
prompt.SendLogs += SendLogs;
135+
prompt.SendCommands += SendCommands;
136+
//prompt.Initiate(dctCommandOne, "UserSpace 1", extension: Feedback);
137+
//prompt.ConsoleInput("coM1(1,2).Help()");
138+
//prompt.ConsoleInput("");
139+
140+
141+
//Assert.IsFalse(_log.Contains("Help com1"), "No help provided.");
142+
//// Assert
143+
//Assert.AreEqual("Input was not valid.", _log, "Error was not catched.");
144+
145+
//prompt.ConsoleInput("mehh");
146+
147+
//Assert.AreEqual("Input was not valid.", _log, "Error was not catched.");
148+
149+
//prompt.ConsoleInput(" yeS ");
150+
151+
//Trace.WriteLine(_outCommand.ToString());
152+
153+
//Assert.IsNotNull(_outCommand, "Out Command was not empty.");
154+
155+
//prompt.ConsoleInput("List().Help()");
156+
//Assert.IsTrue(_log.Contains("You now have the following Options:"), "Wrong Options provided.");
157+
158+
//prompt.ConsoleInput("YeS ");
159+
160+
//Assert.IsTrue(_log.Contains("Special case"), "Wrong Commands listed");
161+
162+
//Trace.WriteLine(_log);
163+
//Trace.WriteLine(_outCommand.ToString());
164+
}
165+
166+
89167
/// <summary>
90168
/// Listen to Messages
91169
/// </summary>

0 commit comments

Comments
 (0)