BadScript 2
Loading...
Searching...
No Matches
BadScript2.Tests.BadLinqTests Class Reference

Public Member Functions

void SelectTest ()
 Tests the LINQ.Select Function.
 
void WhereTest ()
 Tests the LINQ.Where Function.
 
void LastTest ()
 Tests the LINQ.Last Function.
 
void FirstTest ()
 Tests the Linq.First Function.
 
void LastOrDefaultTest ()
 Tests the Linq.LastOrDefault Function.
 
void FirstOrDefaultTest ()
 Tests the Linq.FirstOrDefault Function.
 
void TakeTest ()
 Tests the Linq.Take Function.
 
void SkipTest ()
 Tests the Linq.Skip Function.
 
void TakeLastTest ()
 Tests the Linq.TakeLast Function.
 
void SkipLastTest ()
 Tests the Linq.SkipLast Function.
 
void SelectManyTest ()
 Tests the Linq.SelectMany Function.
 
void SkipWhileTest ()
 Tests the Linq.SkipWhile Function.
 
void TakeWhileTest ()
 Test the Linq.TakeWhile Function.
 
void AllTest ()
 Tests the Linq.All Function.
 
void AnyTest ()
 Tests the Linq.Any Function.
 

Detailed Description

Definition at line 8 of file BadLinqTests.cs.

Member Function Documentation

◆ AllTest()

void BadScript2.Tests.BadLinqTests.AllTest ( )

Tests the Linq.All Function.

Definition at line 199 of file BadLinqTests.cs.

200 {
201 IEnumerable d = Enumerable.Range(0, 100);
202
203 // ReSharper disable once PossibleMultipleEnumeration
204 bool o = d.All("x=>x < 10");
205
206 // ReSharper disable once PossibleMultipleEnumeration
207 bool o1 = d.All("x=>x < 100");
208
209 Assert.Multiple(() =>
210 {
211 Assert.That(o, Is.False);
212 Assert.That(o1, Is.True);
213 }
214 );
215 }

◆ AnyTest()

void BadScript2.Tests.BadLinqTests.AnyTest ( )

Tests the Linq.Any Function.

Definition at line 221 of file BadLinqTests.cs.

222 {
223 IEnumerable d = Enumerable.Range(0, 100);
224
225 // ReSharper disable once PossibleMultipleEnumeration
226 bool o = d.Any("x=>x < 0");
227
228 // ReSharper disable once PossibleMultipleEnumeration
229 bool o1 = d.Any("x=>x < 100");
230 Assert.That(o, Is.False);
231 Assert.That(o1, Is.True);
232 }

◆ FirstOrDefaultTest()

void BadScript2.Tests.BadLinqTests.FirstOrDefaultTest ( )

Tests the Linq.FirstOrDefault Function.

Definition at line 87 of file BadLinqTests.cs.

88 {
89 IEnumerable d = Enumerable.Empty<BadObject>();
90 object? o = d.FirstOrDefault("x=>x%2==0");
91
92 Assert.That(o, Is.Null);
93 }
The Base Class for all BadScript Objects.
Definition BadObject.cs:14

◆ FirstTest()

void BadScript2.Tests.BadLinqTests.FirstTest ( )

Tests the Linq.First Function.

Definition at line 64 of file BadLinqTests.cs.

65 {
66 IEnumerable d = Enumerable.Range(0, 100);
67 object o = d.First("x=>x%2==0");
68 Assert.That(o, Is.InstanceOf<int>());
69 Assert.That(o, Is.EqualTo(0));
70 }

◆ LastOrDefaultTest()

void BadScript2.Tests.BadLinqTests.LastOrDefaultTest ( )

Tests the Linq.LastOrDefault Function.

Definition at line 76 of file BadLinqTests.cs.

77 {
78 IEnumerable d = Enumerable.Empty<BadObject>();
79 object? o = d.LastOrDefault("x=>x%2==0");
80 Assert.That(o, Is.Null);
81 }

◆ LastTest()

void BadScript2.Tests.BadLinqTests.LastTest ( )

Tests the LINQ.Last Function.

Definition at line 52 of file BadLinqTests.cs.

53 {
54 IEnumerable d = Enumerable.Range(0, 100);
55 object o = d.Last("x=>x%2==0");
56 Assert.That(o, Is.InstanceOf<int>());
57 Assert.That(o, Is.EqualTo(98));
58 }

◆ SelectManyTest()

void BadScript2.Tests.BadLinqTests.SelectManyTest ( )

Tests the Linq.SelectMany Function.

Definition at line 156 of file BadLinqTests.cs.

157 {
158 List<BadObject> a = new BadObject[] { 1, 2 }.ToList();
159 IEnumerable d = new BadObject[] { new BadArray(a), new BadArray(a) };
160
161 object[] o = d.SelectMany("x=>x")
162 .Cast<object>()
163 .ToArray();
164 Assert.That(o, Has.Length.EqualTo(4));
165 }
Implements a Dynamic List/Array for the BadScript Language.
Definition BadArray.cs:17

◆ SelectTest()

void BadScript2.Tests.BadLinqTests.SelectTest ( )

Tests the LINQ.Select Function.

Definition at line 14 of file BadLinqTests.cs.

15 {
16 IEnumerable d = Enumerable.Range(0, 100);
17
18 foreach (object? o in d.Select("x=>x*2"))
19 {
20 Assert.Multiple(() =>
21 {
22 Assert.That(o, Is.InstanceOf<decimal>());
23 Assert.That((decimal)o % 2, Is.EqualTo(0));
24 }
25 );
26 }
27 }

◆ SkipLastTest()

void BadScript2.Tests.BadLinqTests.SkipLastTest ( )

Tests the Linq.SkipLast Function.

Definition at line 141 of file BadLinqTests.cs.

142 {
143 IEnumerable d = Enumerable.Range(0, 100);
144
145 object[] o = d.SkipLast(10)
146 .Cast<object>()
147 .ToArray();
148 Assert.That(o, Has.Length.EqualTo(90));
149 }

◆ SkipTest()

void BadScript2.Tests.BadLinqTests.SkipTest ( )

Tests the Linq.Skip Function.

Definition at line 113 of file BadLinqTests.cs.

114 {
115 IEnumerable d = Enumerable.Range(0, 100);
116
117 object[] o = d.Skip(10)
118 .Cast<object>()
119 .ToArray();
120 Assert.That(o, Has.Length.EqualTo(90));
121 }

◆ SkipWhileTest()

void BadScript2.Tests.BadLinqTests.SkipWhileTest ( )

Tests the Linq.SkipWhile Function.

Definition at line 171 of file BadLinqTests.cs.

172 {
173 IEnumerable d = Enumerable.Range(0, 100);
174
175 object[] o = d.SkipWhile("x=>x < 10")
176 .Cast<object>()
177 .ToArray();
178 Assert.That(o, Has.Length.EqualTo(90));
179 }

◆ TakeLastTest()

void BadScript2.Tests.BadLinqTests.TakeLastTest ( )

Tests the Linq.TakeLast Function.

Definition at line 127 of file BadLinqTests.cs.

128 {
129 IEnumerable d = Enumerable.Range(0, 100);
130
131 object[] o = d.TakeLast(10)
132 .Cast<object>()
133 .ToArray();
134 Assert.That(o, Has.Length.EqualTo(10));
135 }

◆ TakeTest()

void BadScript2.Tests.BadLinqTests.TakeTest ( )

Tests the Linq.Take Function.

Definition at line 99 of file BadLinqTests.cs.

100 {
101 IEnumerable d = Enumerable.Range(0, 100);
102
103 object[] o = d.Take(10)
104 .Cast<object>()
105 .ToArray();
106 Assert.That(o, Has.Length.EqualTo(10));
107 }

◆ TakeWhileTest()

void BadScript2.Tests.BadLinqTests.TakeWhileTest ( )

Test the Linq.TakeWhile Function.

Definition at line 185 of file BadLinqTests.cs.

186 {
187 IEnumerable d = Enumerable.Range(0, 100);
188
189 object[] o = d.TakeWhile("x=>x < 10")
190 .Cast<object>()
191 .ToArray();
192 Assert.That(o, Has.Length.EqualTo(10));
193 }

◆ WhereTest()

void BadScript2.Tests.BadLinqTests.WhereTest ( )

Tests the LINQ.Where Function.

Definition at line 33 of file BadLinqTests.cs.

34 {
35 IEnumerable d = Enumerable.Range(0, 100);
36
37 foreach (object? o in d.Where("x=>x%2==0"))
38 {
39 Assert.Multiple(() =>
40 {
41 Assert.That(o, Is.InstanceOf<int>());
42 Assert.That((int)o % 2, Is.EqualTo(0));
43 }
44 );
45 }
46 }

The documentation for this class was generated from the following file: