Skip to content

Commit bf3ffc1

Browse files
add new full example for precise mode
1 parent 4e66676 commit bf3ffc1

File tree

3 files changed

+236
-7
lines changed

3 files changed

+236
-7
lines changed

Testimize/Testimize.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
</PropertyGroup>
1313

1414
<PropertyGroup>
15-
<Version>1.1.6.0</Version>
15+
<Version>1.1.7.0</Version>
1616
<Authors>Anton Angelov</Authors>
1717
<Company>Automate The Planet Ltd.</Company>
1818
<Product>Testimize – Test and Data Generation Library</Product>
19-
<AssemblyVersion>1.1.6.0</AssemblyVersion>
20-
<FileVersion>1.1.6.0</FileVersion>
19+
<AssemblyVersion>1.1.7.0</AssemblyVersion>
20+
<FileVersion>1.1.7.0</FileVersion>
2121
<NeutralLanguage>en</NeutralLanguage>
2222
<Copyright>Copyright © Automate The Planet Ltd. 2025</Copyright>
2323
<PackageLicenseFile>LICENSE</PackageLicenseFile>
@@ -74,6 +74,8 @@
7474
<Content Include="samples\ReqresRegistrationTests.cs" Pack="true" PackagePath="contentFiles\cs\any" />
7575

7676
<Content Include="samples\SampleTests.cs" Pack="true" PackagePath="contentFiles\cs\any" />
77+
78+
<Content Include="samples\PreciseModeFullExample.cs" Pack="true" PackagePath="contentFiles\cs\any" />
7779
</ItemGroup>
7880

7981
<ItemGroup>

Testimize/publishPackageInfo.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
dotnet nuget push "bin\Release\Testimize.1.1.4.nupkg" --api-key %NuGetKey% --source https://api.nuget.org/v3/index.json
1+
dotnet nuget push "bin\Release\Testimize.1.1.7.nupkg" --api-key %NuGetKey% --source https://api.nuget.org/v3/index.json
22

33
or via automatic GitHub Actions:
4-
Only runs when a version tag is pushed, like v1.1.4
4+
Only runs when a version tag is pushed, like v1.1.7
55

6-
git tag v1.1.4
7-
git push origin v1.1.4
6+
git tag v1.1.7
7+
git push origin v1.1.7
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
using NUnit.Framework;
2+
using Testimize.OutputGenerators;
3+
using Testimize.Usage;
4+
5+
namespace Testimize;
6+
7+
[TestFixture]
8+
public class PreciseModeFullExample
9+
{
10+
[Test]
11+
[Ignore("This is used as a template, it is not an actual test")]
12+
public void StartHereToConfigureYourPreciseMode_With_AllRules_FromTestimizeSettings()
13+
{
14+
TestimizeEngine
15+
.Configure(
16+
parameters => parameters
17+
.AddSelect(s => s
18+
.Valid("user@example.com")
19+
.Valid("contact@domain.net")
20+
.Invalid("invalid-email").WithExpectedMessage("Invalid Email value: 'invalid-email'")
21+
.Invalid("plainaddress").WithExpectedMessage("Invalid Email value: 'plainaddress'")
22+
.Invalid("@missingusername.com").WithExpectedMessage("Invalid Email value: '@missingusername.com'")
23+
.Invalid("missingdomain@").WithExpectedMessage("Invalid Email value: 'missingdomain@'")
24+
.Invalid("user@.com").WithExpectedMessage("Invalid Email value: 'user@.com'")
25+
.Invalid("user@domain..com").WithExpectedMessage("Invalid Email value: 'user@domain..com'"))
26+
27+
.AddSelect(s => s
28+
.Valid("+11234567890")
29+
.Valid("+442071838750")
30+
.Invalid("12345").WithExpectedMessage("Invalid Phone value: '12345'")
31+
.Invalid("0000000000").WithExpectedMessage("Invalid Phone value: '0000000000'")
32+
.Invalid("abcdefg").WithExpectedMessage("Invalid Phone value: 'abcdefg'")
33+
.Invalid("+123").WithExpectedMessage("Invalid Phone value: '+123'")
34+
.Invalid("+359 888").WithExpectedMessage("Invalid Phone value: '+359 888'")
35+
.Invalid("+359888BADNUM").WithExpectedMessage("Invalid Phone value: '+359888BADNUM'")
36+
.Invalid("(123) 456-7890-ext").WithExpectedMessage("Invalid Phone value: '(123) 456-7890-ext'"))
37+
38+
.AddSelect(s => s
39+
.Valid("Hello World")
40+
.Valid("Sample Input")
41+
.Invalid("").WithExpectedMessage("Invalid Text value: ''")
42+
.Invalid(" ").WithExpectedMessage("Invalid Text value: ' '")
43+
.Invalid("\n").WithExpectedMessage("Invalid Text value: '\n'")
44+
.Invalid("\t").WithExpectedMessage("Invalid Text value: '\t'")
45+
.Invalid("!@#$%^&*()").WithExpectedMessage("Invalid Text value: '!@#$%^&*()'")
46+
.Invalid("超长文本超长文本超长文本").WithExpectedMessage("Invalid Text value: '超长文本超长文本超长文本'")
47+
.Invalid("<script>alert('XSS')</script>").WithExpectedMessage("Invalid Text value: '<script>alert('XSS')</script>'")
48+
.Invalid("' OR 1=1 --").WithExpectedMessage("Invalid Text value: '' OR 1=1 --'"))
49+
50+
.AddSelect(s => s
51+
.Valid("StrongP@ssw0rd1")
52+
.Valid("Another1#Valid")
53+
.Invalid("12345").WithExpectedMessage("Invalid Password value: '12345'")
54+
.Invalid("password").WithExpectedMessage("Invalid Password value: 'password'")
55+
.Invalid("abc").WithExpectedMessage("Invalid Password value: 'abc'")
56+
.Invalid(" ").WithExpectedMessage("Invalid Password value: ' '"))
57+
58+
.AddSelect(s => s
59+
.Valid("true")
60+
.Valid("false"))
61+
// Optional: Add commented invalids
62+
//.Invalid("yes")
63+
//.Invalid("no")
64+
//.Invalid("1")
65+
//.Invalid("maybe")
66+
67+
.AddSelect(s => s
68+
.Valid("0")
69+
.Valid("42")
70+
.Valid("-100")
71+
.Valid("100000")
72+
.Invalid("abc").WithExpectedMessage("Invalid Integer value: 'abc'")
73+
.Invalid("").WithExpectedMessage("Invalid Integer value: ''")
74+
.Invalid("999999999999999999999").WithExpectedMessage("Invalid Integer value: '999999999999999999999'")
75+
.Invalid("-999999999999999999999").WithExpectedMessage("Invalid Integer value: '-999999999999999999999'"))
76+
77+
.AddSelect(s => s
78+
.Valid("10.5")
79+
.Valid("-100.75")
80+
.Valid("0.00")
81+
.Valid("9999.99")
82+
.Invalid("NaN").WithExpectedMessage("Invalid Decimal value: 'NaN'")
83+
.Invalid("infinity").WithExpectedMessage("Invalid Decimal value: 'infinity'")
84+
.Invalid("text").WithExpectedMessage("Invalid Decimal value: 'text'")
85+
.Invalid("").WithExpectedMessage("Invalid Decimal value: ''")
86+
.Invalid("null").WithExpectedMessage("Invalid Decimal value: 'null'"))
87+
88+
.AddSelect(s => s
89+
.Valid("0.0")
90+
.Valid("50.5")
91+
.Valid("99.99")
92+
.Valid("100.0")
93+
.Invalid("-1").WithExpectedMessage("Invalid Percentage value: '-1'")
94+
.Invalid("101").WithExpectedMessage("Invalid Percentage value: '101'")
95+
.Invalid("text").WithExpectedMessage("Invalid Percentage value: 'text'")
96+
.Invalid("").WithExpectedMessage("Invalid Percentage value: ''"))
97+
98+
.AddSelect(s => s
99+
.Valid("0.0")
100+
.Valid("19.99")
101+
.Valid("100.00")
102+
.Valid("99999.99")
103+
.Invalid("-5").WithExpectedMessage("Invalid Currency value: '-5'")
104+
.Invalid("free").WithExpectedMessage("Invalid Currency value: 'free'")
105+
.Invalid("text").WithExpectedMessage("Invalid Currency value: 'text'")
106+
.Invalid("").WithExpectedMessage("Invalid Currency value: ''"))
107+
108+
.AddSelect(s => s
109+
.Valid("2024-01-01")
110+
.Valid("1990-12-31")
111+
.Valid("2025-03-26")
112+
.Invalid("not-a-date").WithExpectedMessage("Invalid Date value: 'not-a-date'")
113+
.Invalid("13/32/2020").WithExpectedMessage("Invalid Date value: '13/32/2020'")
114+
.Invalid("").WithExpectedMessage("Invalid Date value: ''"))
115+
116+
.AddSelect(s => s
117+
.Valid("00:00")
118+
.Valid("12:30")
119+
.Valid("23:59")
120+
.Invalid("24:00").WithExpectedMessage("Invalid Time value: '24:00'")
121+
.Invalid("99:99").WithExpectedMessage("Invalid Time value: '99:99'")
122+
.Invalid("noon").WithExpectedMessage("Invalid Time value: 'noon'")
123+
.Invalid("").WithExpectedMessage("Invalid Time value: ''"))
124+
125+
.AddSelect(s => s
126+
.Valid("2024-10-01T10:30:00")
127+
.Valid("1999-12-31T23:59:59")
128+
.Valid("2025-03-26T00:00:00")
129+
.Invalid("tomorrow").WithExpectedMessage("Invalid DateTime value: 'tomorrow'")
130+
.Invalid("32/01/2022 25:00").WithExpectedMessage("Invalid DateTime value: '32/01/2022 25:00'")
131+
.Invalid("not-a-datetime").WithExpectedMessage("Invalid DateTime value: 'not-a-datetime'")
132+
.Invalid("").WithExpectedMessage("Invalid DateTime value: ''")
133+
.Invalid("null").WithExpectedMessage("Invalid DateTime value: 'null'"))
134+
135+
.AddSelect(s => s
136+
.Valid("2025-W01")
137+
.Valid("2024-W52")
138+
.Valid("2023-W12")
139+
.Invalid("2025-W60").WithExpectedMessage("Invalid Week value: '2025-W60'")
140+
.Invalid("2024-W00").WithExpectedMessage("Invalid Week value: '2024-W00'")
141+
.Invalid("not-a-week").WithExpectedMessage("Invalid Week value: 'not-a-week'")
142+
.Invalid("").WithExpectedMessage("Invalid Week value: ''"))
143+
144+
.AddSelect(s => s
145+
.Valid("2025-01")
146+
.Valid("2024-12")
147+
.Valid("1999-07")
148+
.Invalid("2025-13").WithExpectedMessage("Invalid Month value: '2025-13'")
149+
.Invalid("1999-00").WithExpectedMessage("Invalid Month value: '1999-00'")
150+
.Invalid("March 2025").WithExpectedMessage("Invalid Month value: 'March 2025'")
151+
.Invalid("").WithExpectedMessage("Invalid Month value: ''"))
152+
153+
.AddSelect(s => s
154+
.Valid("123 Main St, Springfield, IL 62704")
155+
.Valid("456 Elm St, Apt 5B, New York, NY 10001")
156+
.Invalid("").WithExpectedMessage("Invalid Address value: ''")
157+
.Invalid("No Address").WithExpectedMessage("Invalid Address value: 'No Address'")
158+
.Invalid("ZZZ").WithExpectedMessage("Invalid Address value: 'ZZZ'"))
159+
160+
.AddSelect(s => s
161+
.Valid("42.6975,23.3242")
162+
.Valid("48.8566,2.3522")
163+
.Valid("-33.8688,151.2093")
164+
.Invalid("NaN,NaN").WithExpectedMessage("Invalid GeoCoordinate value: 'NaN,NaN'")
165+
.Invalid("999,999").WithExpectedMessage("Invalid GeoCoordinate value: '999,999'")
166+
.Invalid("text").WithExpectedMessage("Invalid GeoCoordinate value: 'text'")
167+
.Invalid("42.6975").WithExpectedMessage("Invalid GeoCoordinate value: '42.6975'")
168+
.Invalid("42.6975,").WithExpectedMessage("Invalid GeoCoordinate value: '42.6975,'")
169+
.Invalid("").WithExpectedMessage("Invalid GeoCoordinate value: ''"))
170+
171+
.AddSelect(s => s
172+
.Valid("john_doe")
173+
.Valid("user123")
174+
.Valid("qa_tester")
175+
.Valid("dev_user1")
176+
.Invalid("admin!").WithExpectedMessage("Invalid Username value: 'admin!'")
177+
.Invalid("user name").WithExpectedMessage("Invalid Username value: 'user name'")
178+
.Invalid("root$").WithExpectedMessage("Invalid Username value: 'root$'")
179+
.Invalid("").WithExpectedMessage("Invalid Username value: ''"))
180+
181+
.AddSelect(s => s
182+
.Valid("https://www.google.com")
183+
.Valid("http://example.org")
184+
.Valid("https://sub.domain.co.uk")
185+
.Invalid("www.google.com").WithExpectedMessage("Invalid URL value: 'www.google.com'")
186+
.Invalid("http:/invalid.com").WithExpectedMessage("Invalid URL value: 'http:/invalid.com'")
187+
.Invalid("ftp://wrong.protocol").WithExpectedMessage("Invalid URL value: 'ftp://wrong.protocol'")
188+
.Invalid("://missing.scheme.com").WithExpectedMessage("Invalid URL value: '://missing.scheme.com'")
189+
.Invalid("").WithExpectedMessage("Invalid URL value: ''"))
190+
191+
.AddSelect(s => s
192+
.Valid("#FF0000")
193+
.Valid("#00FF00")
194+
.Valid("#0000FF")
195+
.Valid("#123ABC")
196+
.Valid("#000000")
197+
.Valid("#FFFFFF")
198+
.Invalid("FF0000").WithExpectedMessage("Invalid Color value: 'FF0000'")
199+
.Invalid("#GGGGGG").WithExpectedMessage("Invalid Color value: '#GGGGGG'")
200+
.Invalid("#12345").WithExpectedMessage("Invalid Color value: '#12345'")
201+
.Invalid("#1234567").WithExpectedMessage("Invalid Color value: '#1234567'")
202+
.Invalid("red").WithExpectedMessage("Invalid Color value: 'red'")
203+
.Invalid("").WithExpectedMessage("Invalid Color value: ''")),
204+
settings =>
205+
{
206+
settings.Mode = TestGenerationMode.HybridArtificialBeeColony;
207+
208+
settings.ABCSettings = new ABCGenerationSettings
209+
{
210+
TotalPopulationGenerations = 20,
211+
MutationRate = 0.3,
212+
FinalPopulationSelectionRatio = 0.5,
213+
EliteSelectionRatio = 0.5,
214+
OnlookerSelectionRatio = 0.1,
215+
ScoutSelectionRatio = 0.3,
216+
EnableOnlookerSelection = true,
217+
EnableScoutPhase = false,
218+
EnforceMutationUniqueness = true,
219+
StagnationThresholdPercentage = 0.75,
220+
CoolingRate = 0.95,
221+
AllowMultipleInvalidInputs = false,
222+
OutputGenerator = new NUnitTestCaseAttributeOutputGenerator()
223+
};
224+
})
225+
.Generate();
226+
}
227+
}

0 commit comments

Comments
 (0)