@@ -24,14 +24,14 @@ public class SaveLoadTestUnityObject : ScriptableObject
2424 public Vector3 pt ;
2525 public Quaternion rot ;
2626 }
27-
27+
2828 [ Serializable ]
2929 public class SaveLoadDictionaryTestObject
3030 {
3131 public Dictionary < string , int > dict = new Dictionary < string , int > ( ) ;
3232 public string name = "" ;
3333 }
34-
34+
3535 private static readonly string BaseDirectory = "GameData" ;
3636 private static readonly string SaveDirectory = "SaveData" ;
3737 private static readonly string TestEncryptionKey = "SaveLoadTestEncryptionKey" ;
@@ -57,19 +57,19 @@ private static void CleanupFiles()
5757 File . Delete ( filepath ) ;
5858 }
5959 }
60-
60+
6161 [ SetUp ]
6262 public void Setup ( )
6363 {
6464 CleanupFiles ( ) ;
6565 }
66-
66+
6767 [ TearDown ]
6868 public void Teardown ( )
6969 {
7070 CleanupFiles ( ) ;
7171 }
72-
72+
7373 [ Test ]
7474 public void CanCreateManager ( [ Values ] SerializationMethodType method )
7575 {
@@ -90,18 +90,25 @@ public void CanSave([Values] SerializationMethodType method)
9090 } ;
9191
9292 const string filename = "Testfile" ;
93-
93+
9494 manager . Save ( testObject , filename ) ;
9595
9696 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
9797 Assert . IsTrue ( File . Exists ( filepath ) ) ;
98-
98+
9999 manager . DeleteSave ( filename ) ;
100100 Assert . IsFalse ( File . Exists ( filepath ) ) ;
101-
101+
102102 Object . Destroy ( manager ) ;
103103 }
104-
104+
105+ [ Test ]
106+ public void GetPath ( [ Values ] SerializationMethodType method )
107+ {
108+ var manager = CreateManager ( method ) ;
109+ Debug . Log ( manager . GetPath ( "MyFile.sav" ) ) ;
110+ }
111+
105112 [ Test ]
106113 public void GetFiles ( [ Values ] SerializationMethodType method )
107114 {
@@ -114,7 +121,7 @@ public void GetFiles([Values] SerializationMethodType method)
114121 } ;
115122
116123 const string filename = "Testfile" ;
117-
124+
118125 manager . Save ( testObject , filename ) ;
119126
120127 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
@@ -123,15 +130,15 @@ public void GetFiles([Values] SerializationMethodType method)
123130 var files = manager . GetFiles ( ) ;
124131 Assert . IsTrue ( files . Length == 1 , $ "Expected 1 file but found { files . Length } ") ;
125132 Assert . IsTrue ( files [ 0 ] == filename ) ;
126-
133+
127134 manager . DeleteSave ( filename ) ;
128135 Assert . IsFalse ( File . Exists ( filepath ) ) ;
129-
136+
130137 Object . Destroy ( manager ) ;
131138 }
132139
133-
134-
140+
141+
135142 [ Test ]
136143 public void CanSaveAndLoad ( [ Values ] SerializationMethodType method )
137144 {
@@ -144,29 +151,29 @@ public void CanSaveAndLoad([Values] SerializationMethodType method)
144151 } ;
145152
146153 const string filename = "Testfile" ;
147-
154+
148155 manager . Save ( testObject , filename ) ;
149156
150157 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
151158 Assert . IsTrue ( File . Exists ( filepath ) ) ;
152159
153160 var loadedObject = manager . Load < SaveLoadTestObject > ( filename ) ;
154-
161+
155162 Assert . IsTrue ( loadedObject . listOfStrings . Count == testObject . listOfStrings . Count ) ;
156163
157164 for ( int i = 0 ; i < testObject . listOfStrings . Count ; i ++ )
158165 {
159166 Assert . IsTrue ( testObject . listOfStrings [ i ] == loadedObject . listOfStrings [ i ] ) ;
160167 }
161-
168+
162169 Assert . IsTrue ( testObject . count == loadedObject . count ) ;
163-
170+
164171 manager . DeleteSave ( filename ) ;
165172 Assert . IsFalse ( File . Exists ( filepath ) ) ;
166-
173+
167174 Object . Destroy ( manager ) ;
168175 }
169-
176+
170177 [ Test ]
171178 public void CanCopy ( [ Values ] SerializationMethodType method )
172179 {
@@ -179,7 +186,7 @@ public void CanCopy([Values] SerializationMethodType method)
179186 } ;
180187
181188 var loadedObject = manager . Copy ( testObject ) ;
182-
189+
183190 Assert . NotNull ( loadedObject ) ;
184191 Assert . IsFalse ( ReferenceEquals ( testObject , loadedObject ) ) ;
185192 Assert . NotNull ( loadedObject . listOfStrings ) ;
@@ -189,12 +196,12 @@ public void CanCopy([Values] SerializationMethodType method)
189196 {
190197 Assert . IsTrue ( testObject . listOfStrings [ i ] == loadedObject . listOfStrings [ i ] ) ;
191198 }
192-
199+
193200 Assert . IsTrue ( testObject . count == loadedObject . count ) ;
194-
201+
195202 Object . Destroy ( manager ) ;
196203 }
197-
204+
198205 [ Test ]
199206 public void LoadReturnsNullWhenFileDoesnotExist ( [ Values ] SerializationMethodType method )
200207 {
@@ -203,7 +210,7 @@ public void LoadReturnsNullWhenFileDoesnotExist([Values] SerializationMethodType
203210
204211 var loadedObject = manager . Load < SaveLoadTestObject > ( filename ) ;
205212 Assert . IsTrue ( loadedObject == null ) ;
206-
213+
207214 Object . Destroy ( manager ) ;
208215 }
209216
@@ -218,17 +225,17 @@ public void CanSaveUnityObject([Values] SerializationMethodType method)
218225 testObj . textValue = "MyValue" ;
219226
220227 manager . SaveUnityObject ( testObj , filename ) ;
221-
228+
222229 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
223230 Assert . IsTrue ( File . Exists ( filepath ) ) ;
224-
231+
225232 manager . DeleteSave ( filename ) ;
226233 Assert . IsFalse ( File . Exists ( filepath ) ) ;
227-
234+
228235 Object . Destroy ( testObj ) ;
229236 Object . Destroy ( manager ) ;
230237 }
231-
238+
232239 [ Test ]
233240 public void CanSaveLoadUnityObject ( [ Values ] SerializationMethodType method )
234241 {
@@ -241,16 +248,16 @@ public void CanSaveLoadUnityObject([Values] SerializationMethodType method)
241248 testObj . textValue = "MyValue" ;
242249
243250 manager . SaveUnityObject ( testObj , filename ) ;
244-
251+
245252 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
246253 Assert . IsTrue ( File . Exists ( filepath ) ) ;
247-
254+
248255 manager . LoadUnityObjectOverwrite ( loadedTestObj , filename ) ;
249256 Assert . IsTrue ( loadedTestObj . textValue == testObj . textValue ) ;
250-
257+
251258 manager . DeleteSave ( filename ) ;
252259 Assert . IsFalse ( File . Exists ( filepath ) ) ;
253-
260+
254261 Object . Destroy ( testObj ) ;
255262 Object . Destroy ( loadedTestObj ) ;
256263 Object . Destroy ( manager ) ;
@@ -264,16 +271,16 @@ public void CanCopyUnityObject([Values] SerializationMethodType method)
264271 var loadedTestObj = ScriptableObject . CreateInstance < SaveLoadTestUnityObject > ( ) ;
265272
266273 testObj . textValue = "MyValue" ;
267-
274+
268275 manager . CopyUnityObjectOverwrite ( testObj , loadedTestObj ) ;
269276
270277 Assert . IsTrue ( loadedTestObj . textValue == testObj . textValue ) ;
271-
278+
272279 Object . Destroy ( testObj ) ;
273280 Object . Destroy ( loadedTestObj ) ;
274281 Object . Destroy ( manager ) ;
275282 }
276-
283+
277284 [ Test ]
278285 public void CopyThrowsArgumentExceptionOnUnityObject ( [ Values ] SerializationMethodType method )
279286 {
@@ -284,7 +291,7 @@ public void CopyThrowsArgumentExceptionOnUnityObject([Values] SerializationMetho
284291 {
285292 manager . Copy ( testObj ) ;
286293 } ) ;
287-
294+
288295 Object . Destroy ( testObj ) ;
289296 Object . Destroy ( manager ) ;
290297 }
@@ -305,21 +312,21 @@ public void CanSaveAndLoadDictionary([Values(
305312 {
306313 dict = new Dictionary < string , int >
307314 {
308- { "one" , 1 } ,
315+ { "one" , 1 } ,
309316 { "two" , 2 }
310317 } ,
311318 name = "Test" ,
312319 } ;
313320
314321 const string filename = "Testfile" ;
315-
322+
316323 manager . Save ( testObject , filename ) ;
317324
318325 var filepath = $ "{ SaveLoadUtility . GetSavePath ( SaveDirectory , BaseDirectory ) } /{ filename } ";
319326 Assert . IsTrue ( File . Exists ( filepath ) ) ;
320327
321328 var loadedObject = manager . Load < SaveLoadDictionaryTestObject > ( filename ) ;
322-
329+
323330 Assert . IsTrue ( loadedObject . name == testObject . name ) ;
324331 Assert . IsTrue ( loadedObject . dict . Count == testObject . dict . Count ) ;
325332 Assert . IsTrue ( loadedObject . dict . ContainsKey ( "one" ) ) ;
@@ -329,9 +336,9 @@ public void CanSaveAndLoadDictionary([Values(
329336
330337 manager . DeleteSave ( filename ) ;
331338 Assert . IsFalse ( File . Exists ( filepath ) ) ;
332-
339+
333340 Object . Destroy ( manager ) ;
334341 }
335-
342+
336343 }
337344}
0 commit comments