@@ -15,51 +15,108 @@ public class PhotoLapseTests
1515 private static readonly string imagesPath = "../../images/" ;
1616
1717 [ TestMethod ]
18- public void TestStripes ( )
19- {
20- IPhotoLapseCreator stripe = new StripePhotoLapseCreator ( ) ;
21- Test ( stripe , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe111111.bmp" ) ;
22- Test ( stripe , new List < float > { 1 , 2 , 1 , 2 , 1 , 2 } , "stripe121212.bmp" ) ;
23- Test ( stripe , new List < float > { 0 , 1 , 0 , 1 , 0 , 1 } , "stripe010101.bmp" ) ;
24- Test ( stripe , new List < float > { 1 , 0 , 1 , 0 , 1 , 0 } , "stripe101010.bmp" ) ;
25- Test ( stripe , new List < float > { 1 , 0 , 0 , 0 , 0 , 0 } , "stripe100000.bmp" ) ;
26- Test ( stripe , new List < float > { 0 , 0 , 0 , 0 , 0 , 1 } , "stripe000001.bmp" ) ;
27- Test ( stripe , new List < float > { 0 , 0 , 1 , 0 , 0 , 0 } , "stripe001000.bmp" ) ;
28- Test ( stripe , new List < float > { 1 , 2 , 3 , 4 , 5 , 6 } , "stripe123456.bmp" ) ;
29- Test ( new StripePhotoLapseCreator ( 10 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_10.bmp" ) ;
30- Test ( new StripePhotoLapseCreator ( 20 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_20.bmp" ) ;
31- Test ( new StripePhotoLapseCreator ( 30 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_30.bmp" ) ;
32- Assert . IsTrue ( true ) ;
18+ public void TestStripes111111 ( )
19+ {
20+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe111111.bmp" ) ) ;
21+ }
22+
23+ [ TestMethod ]
24+ public void TestStripes121212 ( )
25+ {
26+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 1 , 2 , 1 , 2 , 1 , 2 } , "stripe121212.bmp" ) ) ;
3327 }
3428
3529 [ TestMethod ]
36- public void TestGradient ( )
30+ public void TestStripes010101 ( )
3731 {
38- IPhotoLapseCreator grad = new GradientPhotoLapseCreator ( ) ;
39- Test ( grad , new List < float > { 1 , 1 , 1 , 1 , 1 } , "gradient11111.bmp" ) ;
40- Test ( grad , new List < float > { 1 , 2 , 1 , 2 , 1 } , "gradient12121.bmp" ) ;
41- Test ( grad , new List < float > { 1 , 0 , 0 , 0 , 0 } , "gradient10000.bmp" ) ;
42- Test ( grad , new List < float > { 1 , 1 , 1 , 3 , 1 } , "gradient11131.bmp" ) ;
43- Assert . IsTrue ( true ) ;
32+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 0 , 1 , 0 , 1 , 0 , 1 } , "stripe010101.bmp" ) ) ;
4433 }
4534
46- public void Test ( IPhotoLapseCreator creator , List < float > weights , string expected )
35+ [ TestMethod ]
36+ public void TestStripes101010 ( )
37+ {
38+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 1 , 0 , 1 , 0 , 1 , 0 } , "stripe101010.bmp" ) ) ;
39+ }
40+
41+ [ TestMethod ]
42+ public void TestStripes100000 ( )
43+ {
44+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 1 , 0 , 0 , 0 , 0 , 0 } , "stripe100000.bmp" ) ) ;
45+ }
46+
47+ [ TestMethod ]
48+ public void TestStripes000001 ( )
49+ {
50+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 0 , 0 , 0 , 0 , 0 , 1 } , "stripe000001.bmp" ) ) ;
51+ }
52+
53+ [ TestMethod ]
54+ public void TestStripes001000 ( )
55+ {
56+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 0 , 0 , 1 , 0 , 0 , 0 } , "stripe001000.bmp" ) ) ;
57+ }
58+
59+ [ TestMethod ]
60+ public void TestStripes123456 ( )
61+ {
62+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( ) , new List < float > { 1 , 2 , 3 , 4 , 5 , 6 } , "stripe123456.bmp" ) ) ;
63+ }
64+
65+ [ TestMethod ]
66+ public void TestStripesPad10 ( )
67+ {
68+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( 10 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_10.bmp" ) ) ;
69+ }
70+
71+ [ TestMethod ]
72+ public void TestStripesPad20 ( )
73+ {
74+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( 20 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_20.bmp" ) ) ;
75+ }
76+
77+ [ TestMethod ]
78+ public void TestStripesPad30 ( )
79+ {
80+ Assert . IsTrue ( Test ( new StripePhotoLapseCreator ( 30 ) , new List < float > { 1 , 1 , 1 , 1 , 1 , 1 } , "stripe_pad_30.bmp" ) ) ;
81+ }
82+
83+ [ TestMethod ]
84+ public void TestGradient11111 ( )
85+ {
86+ Assert . IsTrue ( Test ( new GradientPhotoLapseCreator ( ) , new List < float > { 1 , 1 , 1 , 1 , 1 } , "gradient11111.bmp" ) ) ;
87+ }
88+
89+ [ TestMethod ]
90+ public void TestGradient12121 ( )
91+ {
92+ Assert . IsTrue ( Test ( new GradientPhotoLapseCreator ( ) , new List < float > { 1 , 2 , 1 , 2 , 1 } , "gradient12121.bmp" ) ) ;
93+ }
94+
95+ [ TestMethod ]
96+ public void TestGradient10000 ( )
97+ {
98+ Assert . IsTrue ( Test ( new GradientPhotoLapseCreator ( ) , new List < float > { 1 , 0 , 0 , 0 , 0 } , "gradient10000.bmp" ) ) ;
99+ }
100+
101+ [ TestMethod ]
102+ public void TestGradient11131 ( )
103+ {
104+ Assert . IsTrue ( Test ( new GradientPhotoLapseCreator ( ) , new List < float > { 1 , 1 , 1 , 3 , 1 } , "gradient11131.bmp" ) ) ;
105+ }
106+
107+ public bool Test ( IPhotoLapseCreator creator , List < float > weights , string expected )
47108 {
48109 List < string > fullPath = images . Select ( i => imagesPath + i ) . ToList ( ) ;
49110 using ( Bitmap resultBmp = creator . Process ( fullPath , weights ) )
50111 using ( Bitmap expectedBmp = new Bitmap ( imagesPath + expected ) )
51- {
52- Assert . IsTrue ( Compare ( resultBmp , expectedBmp , 1 ) ) ;
53- }
112+ return Compare ( resultBmp , expectedBmp , 1 ) ;
54113 }
55114
56115 public void Generate ( IPhotoLapseCreator creator , List < float > weights , string output )
57116 {
58117 List < string > fullPath = images . Select ( i => imagesPath + i ) . ToList ( ) ;
59118 using ( Bitmap result = creator . Process ( fullPath , weights ) )
60- {
61119 result . Save ( imagesPath + output ) ;
62- }
63120 }
64121
65122 private static bool Compare ( Bitmap actual , Bitmap expected , int tolerance )
0 commit comments