1+ /*
2+ Figment
3+ Copyright (C) 2025 Sean McElroy
4+
5+ This program is free software: you can redistribute it and/or modify
6+ it under the terms of the GNU Affero General Public License as published by
7+ the Free Software Foundation, either version 3 of the License, or
8+ (at your option) any later version.
9+
10+ This program is distributed in the hope that it will be useful,
11+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ GNU Affero General Public License for more details.
14+
15+ You should have received a copy of the GNU Affero General Public License
16+ along with this program. If not, see <http://www.gnu.org/licenses/>.
17+ */
18+
19+ using jot . Commands . Interactive ;
20+ using jot . Test . TestUtilities ;
21+ using Spectre . Console . Cli ;
22+
23+ namespace jot . Test . Commands . Interactive ;
24+
25+ [ TestClass ]
26+ public class SelectCommandTests : CommandTestBase
27+ {
28+ protected override void ConfigureCommands ( CommandApp app )
29+ {
30+ app . Configure ( config =>
31+ {
32+ config . AddCommand < SelectCommand > ( "select" ) ;
33+ } ) ;
34+ }
35+
36+ [ TestMethod ]
37+ public async Task ExecuteAsync_WithValidSchemaName_ShouldSelectSchema ( )
38+ {
39+ // Arrange
40+ var schema = await TestStorageSetup . CreateAndSaveSchemaAsync ( StorageProvider , "TestSchema" ) ;
41+
42+ // Act
43+ var result = await ExecuteCommandAsync ( "select" , "--schema" , "TestSchema" ) ;
44+
45+ // Assert
46+ Assert . AreEqual ( 0 , result . ExitCode ) ;
47+ // Note: In real implementation, this would set the selected schema in global state
48+ }
49+
50+ [ TestMethod ]
51+ public async Task ExecuteAsync_WithValidThingName_ShouldSelectThing ( )
52+ {
53+ // Arrange
54+ var ( schema , things ) = await TestStorageSetup . CreateTestDataSetAsync ( StorageProvider ) ;
55+ var thing = things . First ( ) ;
56+
57+ // Act
58+ var result = await ExecuteCommandAsync ( "select" , "--thing" , thing . Name ) ;
59+
60+ // Assert
61+ Assert . AreEqual ( 0 , result . ExitCode ) ;
62+ // Note: In real implementation, this would set the selected thing in global state
63+ }
64+
65+ [ TestMethod ]
66+ public async Task ExecuteAsync_WithNonExistentSchema_ShouldReturnError ( )
67+ {
68+ // Act
69+ var result = await ExecuteCommandAsync ( "select" , "--schema" , "NonExistentSchema" ) ;
70+
71+ // Assert
72+ Assert . AreNotEqual ( 0 , result . ExitCode ) ;
73+ }
74+
75+ [ TestMethod ]
76+ public async Task ExecuteAsync_WithNonExistentThing_ShouldReturnError ( )
77+ {
78+ // Act
79+ var result = await ExecuteCommandAsync ( "select" , "--thing" , "NonExistentThing" ) ;
80+
81+ // Assert
82+ Assert . AreNotEqual ( 0 , result . ExitCode ) ;
83+ }
84+
85+ [ TestMethod ]
86+ public async Task ExecuteAsync_WithNoParameters_ShouldShowCurrentSelection ( )
87+ {
88+ // Act
89+ var result = await ExecuteCommandAsync ( "select" ) ;
90+
91+ // Assert
92+ Assert . AreEqual ( 0 , result . ExitCode ) ;
93+ }
94+ }
0 commit comments