1+ using System . IO ;
2+ using NUnit . Framework ;
3+ using FileRenamer . Core ;
4+ using FileRenamer . Core . Extensions ;
5+ using FileRenamer . Core . Indices ;
6+ using FileRenamer . Core . Jobs ;
7+ using FileRenamer . Core . Jobs . FileActions ;
8+ using FileRenamer . Core . ValueSources ;
9+ using FileRenamer . Core . ValueSources . NumberFormatters ;
10+
11+
12+ namespace FileRenamer . Core_Tester ;
13+
14+ [ TestFixture ]
15+ public static class Test_Project
16+ {
17+ [ Test ]
18+ public static async void TestRun1 ( )
19+ {
20+ JobCollection jobCollection = new ( )
21+ {
22+ new InsertAction ( new BeginningIndex ( ) , new StringValueSource ( "My name is " ) ) ,
23+ new InsertAction ( new BeginningIndex ( ) , new RandomStringValueSource ( ) { IncludeLowercase = true , IncludeUppercase = false , IncludeNumbers = true , IncludeSymbols = false , Length = 28 } ) ,
24+ new InsertAction ( new BeginningIndex ( ) , new FolderNameValueSource ( ) ) ,
25+ new InsertAction ( new EndIndex ( ) , new CounterValueSource ( ) { InitialValue = 0 , Increment = 1 } ) ,
26+ new InsertAction ( new EndIndex ( ) , new CounterValueSource ( ) { InitialValue = 1 , Increment = 2 , Formatter = new PaddedNumberFormatter ( ) { MinWidth = 5 , PaddingChar = 't' } } ) ,
27+ new InsertAction ( new EndIndex ( ) , new CounterValueSource ( ) { InitialValue = 2 , Increment = 3 , Formatter = new NumberToWordsFormatter ( ) { Gender = Humanizer . GrammaticalGender . Feminine , UseUppercase = false } } ) ,
28+ new InsertAction ( new EndIndex ( ) , new CounterValueSource ( ) { InitialValue = 3 , Increment = 4 , Formatter = new RomanNumberFormatter ( ) { UseUppercase = true } } ) ,
29+ new RemoveAction ( new SubstringIndex ( "Jack Pearson" , true , false , true ) , 8 ) ,
30+ new ChangeRangeCaseAction ( new FixedIndex ( 1 ) , new FileExtensionIndex ( ) , TextCasing . TitleCase ) ,
31+ } ;
32+
33+ Project project = new ( jobCollection ) ;
34+
35+ using MemoryStream writeStream = new ( ) ;
36+ await project . WriteXmlAsync ( writeStream ) ;
37+
38+ writeStream . Position = 0 ;
39+ using StreamReader readStream = new ( writeStream , System . Text . Encoding . UTF8 ) ;
40+ Project project2 = await Project . ReadXmlAsync ( readStream ) ;
41+
42+
43+ Assert . AreEqual ( project . Jobs . Count , project2 . Jobs . Count ) ;
44+ }
45+ }
0 commit comments