11using GS2Engine . Enums ;
22using GS2Engine . Extensions ;
3+ using GS2Engine . GS2 . Script ;
34using GS2Engine . Models ;
45
56namespace GS2Engine . UnitTests
@@ -81,6 +82,21 @@ public void When_input_is_string_Then_return_StackEntry_with_type_string_and_val
8182 Assert . Equal ( val , test . GetValue ( ) ? . ToString ( ) ) ;
8283 }
8384
85+ [ Fact ]
86+ public void When_input_is_TString_Then_return_StackEntry_with_type_string_and_value_type_TString ( )
87+ {
88+ //Arrange
89+ TString val = "test" ;
90+
91+ //Act
92+ IStackEntry test = val . ToStackEntry ( ) ;
93+
94+ //Assert
95+ Assert . Equal ( StackEntryType . String , test . Type ) ;
96+ Assert . Equal ( typeof ( TString ) , test . GetValue ( ) ? . GetType ( ) ) ;
97+ Assert . Equal ( val , test . GetValue ( ) ? . ToString ( ) ) ;
98+ }
99+
84100 [ Fact ]
85101 public void When_input_is_string_array_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
86102 {
@@ -96,6 +112,93 @@ public void When_input_is_string_array_Then_return_StackEntry_with_type_array_an
96112 Assert . Equal ( val , test . GetValue ( ) ) ;
97113 }
98114
115+ [ Fact ]
116+ public void When_input_is_int_array_Then_return_StackEntry_with_type_array_and_value_type_List_int ( )
117+ {
118+ //Arrange
119+ int [ ] val = { 1 , 2 } ;
120+
121+ //Act
122+ IStackEntry test = val . ToStackEntry ( ) ;
123+
124+ //Assert
125+ Assert . Equal ( StackEntryType . Array , test . Type ) ;
126+ Assert . Equal ( typeof ( List < int > ) , test . GetValue ( ) ? . GetType ( ) ) ;
127+ Assert . Equal ( val , test . GetValue ( ) ) ;
128+ }
129+
130+ [ Fact ]
131+ public void When_input_is_command_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
132+ {
133+ //Arrange
134+ Script . Command val = ( _ , _ ) => 0 . ToStackEntry ( ) ;
135+
136+ //Act
137+ IStackEntry test = val . ToStackEntry ( ) ;
138+
139+ //Assert
140+ Assert . Equal ( StackEntryType . Function , test . Type ) ;
141+ Assert . Equal ( typeof ( Script . Command ) , test . GetValue ( ) ? . GetType ( ) ) ;
142+ Assert . Equal ( val , test . GetValue ( ) ) ;
143+ }
144+
145+ [ Fact ]
146+ public void When_input_is_guicontrol_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
147+ {
148+ //Arrange
149+ IGuiControl val = new GuiControl ( "" , null ) ;
150+
151+ //Act
152+ IStackEntry test = val . ToStackEntry ( ) ;
153+
154+ //Assert
155+ Assert . Equal ( StackEntryType . Array , test . Type ) ;
156+ Assert . Equal ( typeof ( GuiControl ) , test . GetValue ( ) ? . GetType ( ) ) ;
157+ Assert . Equal ( val , test . GetValue ( ) ) ;
158+ }
159+
160+ [ Fact ]
161+ public void When_input_is_variablecollection_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
162+ {
163+ //Arrange
164+ VariableCollection val = new ( ) ;
165+
166+ //Act
167+ IStackEntry test = val . ToStackEntry ( ) ;
168+
169+ //Assert
170+ Assert . Equal ( StackEntryType . Array , test . Type ) ;
171+ Assert . Equal ( typeof ( VariableCollection ) , test . GetValue ( ) ? . GetType ( ) ) ;
172+ Assert . Equal ( val , test . GetValue ( ) ) ;
173+ }
174+
175+ [ Fact ]
176+ public void When_input_is_typeof_list_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
177+ {
178+ //Arrange
179+ List < object > val = new ( ) ;
180+
181+ //Act
182+ IStackEntry test = val . ToStackEntry ( ) ;
183+
184+ //Assert
185+ Assert . Equal ( StackEntryType . Array , test . Type ) ;
186+ Assert . Equal ( typeof ( List < object > ) , test . GetValue ( ) ? . GetType ( ) ) ;
187+ Assert . Equal ( val , test . GetValue ( ) ) ;
188+ }
189+
190+ [ Fact ]
191+ public void When_input_is_outofrange_Then_return_StackEntry_with_type_array_and_value_type_List_string ( )
192+ {
193+ //Arrange
194+ Thread val = new ( _ => { } ) ;
195+
196+ //Act
197+ //Assert
198+ ArgumentOutOfRangeException exception = Assert . Throws < ArgumentOutOfRangeException > ( ( ) => val . ToStackEntry ( ) ) ;
199+ Assert . Equal ( "Specified argument was out of the range of valid values." , exception . Message ) ;
200+ }
201+
99202 [ Fact ]
100203 public void When_input_is_bool_Then_return_StackEntry_with_type_bool_and_value_type_bool ( )
101204 {
0 commit comments