diff --git a/YourFirstPSModuleInCSharp.sln b/YourFirstPSModuleInCSharp.sln
index 1f937bc..950ce9b 100644
--- a/YourFirstPSModuleInCSharp.sln
+++ b/YourFirstPSModuleInCSharp.sln
@@ -19,6 +19,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.7.PowerShell.MultiT
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.4.Hybrid", "src\Example.4.Hybrid\Example.4.Hybrid.csproj", "{FE5DF71E-4AE5-4440-AD30-A9588E92CE21}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab.1.RandomEmail", "src\Lab.1.RandomEmail\Lab.1.RandomEmail.csproj", "{2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab.2.RandomSentence", "src\Lab.2.RandomSentence\Lab.2.RandomSentence.csproj", "{50408EFA-E99F-4A90-BFF7-A4AB8518BFC6}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab.3.Bouncer", "src\Lab.3.Bouncer\Lab.3.Bouncer.csproj", "{1EA614E4-F977-4CC3-AA27-1D609CC289D2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -56,6 +62,18 @@ Global
{FE5DF71E-4AE5-4440-AD30-A9588E92CE21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FE5DF71E-4AE5-4440-AD30-A9588E92CE21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FE5DF71E-4AE5-4440-AD30-A9588E92CE21}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {50408EFA-E99F-4A90-BFF7-A4AB8518BFC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {50408EFA-E99F-4A90-BFF7-A4AB8518BFC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {50408EFA-E99F-4A90-BFF7-A4AB8518BFC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {50408EFA-E99F-4A90-BFF7-A4AB8518BFC6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {1EA614E4-F977-4CC3-AA27-1D609CC289D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {1EA614E4-F977-4CC3-AA27-1D609CC289D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {1EA614E4-F977-4CC3-AA27-1D609CC289D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {1EA614E4-F977-4CC3-AA27-1D609CC289D2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C686146C-58E6-4D85-B36D-8E1AC5F18D7C} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
@@ -65,5 +83,8 @@ Global
{9D4F9AAA-D7A5-4C61-8352-DA050AD934DA} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
{69B43DD8-1DA6-4556-A813-4570786B162E} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
{FE5DF71E-4AE5-4440-AD30-A9588E92CE21} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
+ {2713ADDB-20DA-43C2-AE4D-1F2DCA6675D3} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
+ {50408EFA-E99F-4A90-BFF7-A4AB8518BFC6} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
+ {1EA614E4-F977-4CC3-AA27-1D609CC289D2} = {8142F2E5-265E-4F9F-A9C9-EA30A735ABD7}
EndGlobalSection
EndGlobal
diff --git a/src/Lab.1.RandomEmail/GetPEURandomEmailCmdlet.cs b/src/Lab.1.RandomEmail/GetPEURandomEmailCmdlet.cs
new file mode 100644
index 0000000..165fcb7
--- /dev/null
+++ b/src/Lab.1.RandomEmail/GetPEURandomEmailCmdlet.cs
@@ -0,0 +1,18 @@
+namespace PEURandom;
+using System.Management.Automation;
+using System.Net.Mail;
+using LoremNET;
+
+[Cmdlet(VerbsCommon.Get, "PEURandomEmail")]
+public class GetPEURandomEmailCmdlet : PSCmdlet
+{
+ [Parameter()]
+ public SwitchParameter UsernameOnly;
+
+ protected override void EndProcessing()
+ {
+ MailAddress email = new(Lorem.Email());
+ string output = UsernameOnly ? email.User : email.ToString();
+ WriteObject(output);
+ }
+}
\ No newline at end of file
diff --git a/src/Lab.1.RandomEmail/Lab.1.RandomEmail.csproj b/src/Lab.1.RandomEmail/Lab.1.RandomEmail.csproj
new file mode 100644
index 0000000..bdec73d
--- /dev/null
+++ b/src/Lab.1.RandomEmail/Lab.1.RandomEmail.csproj
@@ -0,0 +1,32 @@
+
+
+
+
+ net6.0
+
+
+ en
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Lab.2.RandomSentence/GetPEURandomSentenceCmdlet.cs b/src/Lab.2.RandomSentence/GetPEURandomSentenceCmdlet.cs
new file mode 100644
index 0000000..e80b940
--- /dev/null
+++ b/src/Lab.2.RandomSentence/GetPEURandomSentenceCmdlet.cs
@@ -0,0 +1,26 @@
+namespace PEURandom;
+using System.Management.Automation;
+using LoremNET;
+
+[Cmdlet(VerbsCommon.Get, "PEURandomSentence")]
+public class GetPEURandomSentenceCmdlet : PSCmdlet
+{
+ [Parameter(ValueFromPipeline = true)]
+ public string Name;
+
+ [Parameter()]
+ public int Min = 5;
+ [Parameter()]
+ public int Max = 10;
+
+ protected override void ProcessRecord()
+ {
+ var randomSentence = Lorem.Sentence(Min, Max);
+ if (Name is not null) {
+ randomSentence = randomSentence.Replace(".$", string.Empty) + $", {Name}";
+ }
+ WriteObject(
+ randomSentence
+ );
+ }
+}
\ No newline at end of file
diff --git a/src/Lab.2.RandomSentence/Lab.2.RandomSentence.csproj b/src/Lab.2.RandomSentence/Lab.2.RandomSentence.csproj
new file mode 100644
index 0000000..bdec73d
--- /dev/null
+++ b/src/Lab.2.RandomSentence/Lab.2.RandomSentence.csproj
@@ -0,0 +1,32 @@
+
+
+
+
+ net6.0
+
+
+ en
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Lab.3.Bouncer/AssertPEUAgeCmdlet.cs b/src/Lab.3.Bouncer/AssertPEUAgeCmdlet.cs
new file mode 100644
index 0000000..2d0d38e
--- /dev/null
+++ b/src/Lab.3.Bouncer/AssertPEUAgeCmdlet.cs
@@ -0,0 +1,28 @@
+using System;
+using System.IO;
+using System.Management.Automation;
+
+namespace PEURandom;
+
+[Cmdlet(VerbsLifecycle.Assert, "PEUAge")]
+[OutputType(typeof(Person))]
+public class AssertPEUAgeCmdlet : PSCmdlet
+{
+ [Parameter(Position = 0, ValueFromPipeline = true)]
+ public IPerson Person;
+
+ [Parameter()]
+ public int Age = 18;
+
+ protected override void ProcessRecord()
+ {
+ const int daysInAYear = 365;
+ var ageSpan = DateTime.Now - Person.BirthDate;
+ int personAge = (int)Math.Floor(ageSpan.TotalDays / daysInAYear);
+ if (personAge < Age) {
+ throw new InvalidDataException($"{Person.Name} is under the age of {Age}");
+ }
+
+ WriteObject(Person);
+ }
+}
\ No newline at end of file
diff --git a/src/Lab.3.Bouncer/GetPEUAgeCmdlet.cs b/src/Lab.3.Bouncer/GetPEUAgeCmdlet.cs
new file mode 100644
index 0000000..684c326
--- /dev/null
+++ b/src/Lab.3.Bouncer/GetPEUAgeCmdlet.cs
@@ -0,0 +1,26 @@
+using System.Management.Automation;
+using LoremNET;
+
+namespace PEURandom;
+
+[Cmdlet(VerbsCommon.Get, "PEUAge")]
+[OutputType(typeof(Person))]
+public class GetPEUAgeCmdlet : PSCmdlet
+{
+ [Parameter(Position = 0, ValueFromPipeline = true, Mandatory = true)]
+ public string Name;
+
+ protected override void ProcessRecord()
+ {
+ WriteObject(
+ GetPerson()
+ );
+ }
+
+ Person GetPerson() {
+ return new Person(
+ Name,
+ Lorem.DateTime()
+ );
+ }
+}
\ No newline at end of file
diff --git a/src/Lab.3.Bouncer/Lab.3.Bouncer.csproj b/src/Lab.3.Bouncer/Lab.3.Bouncer.csproj
new file mode 100644
index 0000000..bdec73d
--- /dev/null
+++ b/src/Lab.3.Bouncer/Lab.3.Bouncer.csproj
@@ -0,0 +1,32 @@
+
+
+
+
+ net6.0
+
+
+ en
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Lab.3.Bouncer/Person.cs b/src/Lab.3.Bouncer/Person.cs
new file mode 100644
index 0000000..4cfc1ce
--- /dev/null
+++ b/src/Lab.3.Bouncer/Person.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace PEURandom;
+
+public interface IPerson {
+ string Name { get; }
+ DateTime BirthDate { get; }
+}
+
+public record Person(string Name, DateTime BirthDate) : IPerson;
diff --git a/tests/Lab.2.RandomSentence.Tests.ps1 b/tests/Lab.2.RandomSentence.Tests.ps1
index 9ce4014..7de1368 100644
--- a/tests/Lab.2.RandomSentence.Tests.ps1
+++ b/tests/Lab.2.RandomSentence.Tests.ps1
@@ -28,7 +28,7 @@ Describe 'Lab 2: Get a random sentence' {
}
Context 'Names Via Pipeline' {
BeforeAll {
- $name = 'Pester1', 'Pester2', 'Pester3'
+ $name = 'Pester1','Pester2','Pester3'
$SCRIPT:actual = $name | Get-PEURandomSentence
}
@@ -42,7 +42,7 @@ Describe 'Lab 2: Get a random sentence' {
}
It 'Each sentence ends with the corresponding name provided via the pipeline' {
- # Check that each item output matches the corresponding name.
+ # Check that each item output matches the corresponding name.
#NOTE: This is a bad test if you are attempting to do things in parallel as they will possibly arrive out of order, but it is fine here.
$i = 0
foreach ($actualItem in $actual) {