Browse Source

Wrote basic unit tests.

Null checks for public facing library code.
master
Craig Oates 6 years ago
parent
commit
b1e4ffe126
  1. 9
      TestCentre/Script.fsx
  2. 3
      TestCentre/TestCentre.fsproj
  3. 12
      TestCentre/UnitTests.fs
  4. 21
      TestCentre/txt Files/console-waterworks-announcement.txt
  5. 14
      TestCentre/txt Files/desktop-clock-info.txt
  6. 8
      TestCentre/txt Files/word-generator.txt

9
TestCentre/Script.fsx

@ -1,8 +1 @@
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
#load "Library1.fs"
open TestCentre
// Define your library scripting code here
// nothing in here for now.

3
TestCentre/TestCentre.fsproj

@ -55,6 +55,9 @@
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<ItemGroup>
<Content Include="txt Files\desktop-clock-info.txt" />
<Content Include="txt Files\console-waterworks-announcement.txt" />
<Content Include="txt Files\word-generator.txt" />
<Compile Include="AssemblyInfo.fs" />
<Compile Include="UnitTests.fs" />
<None Include="Script.fsx" />

12
TestCentre/UnitTests.fs

@ -6,6 +6,16 @@ open WetPancake
module UnitTests =
[<Fact>]
let ``Random Text does not generate a null`` () =
let ``Request Random Text does not generate a null`` () =
let result = Pancake.RequestRandomText
Assert.NotNull result
[<Fact>]
let ``Request Text does not generate a null`` () =
let result = Pancake.RequestText 5 5
Assert.NotNull result
[<Fact>]
let ``Request Text From File does not generate a null`` () =
let result = Pancake.RequestTextFromFile 5 5 (__SOURCE_DIRECTORY__ + "\\txt Files\\word-generator.txt")
Assert.NotNull result

21
TestCentre/txt Files/console-waterworks-announcement.txt

@ -0,0 +1,21 @@
That's right, you've won. Well done and come on down, today is not your lucky day. It's -- in fact -- the best day of your life. How else can you describe the moment you discovered the Console.Waterworks NuGet package? That's right, you can't. So, let's get on with basking in your glory. I can't wait.
First of all, Console.Waterworks is for writing extendable command-based console programs. Gone are the days where you need to parse user input and write error handling code. You now have the ability to write methods which act as commands at run-time. Method parameters are, also, accepted and parsed at run-time. This is brilliant and in need of a demonstration. Are you ready to see something which surpasses the hype and majesty of the sun herself? Well, come on then. It's demo. time.
As you can see in the Gif. above, the method I have written (on the left) maps to a command in the console program at run-time (on the right). There is no parsing of user input or error handling in the code, either. Don't worry, you'll be reading more about that majestic trick-shot in a moment. For now, enjoy the flashing lights. You've earned it.
We both know you're not an idiot. So, when you recognise the brilliance, you know it's one-hundred percent legitimate. This is a fair assessment. And, this next intellectual marvel will elevate your core being to a state of ecstasy. Yes, you're right. I'm about to render you stupid through the sheer splendour of intellectual stimulation. It's going to be so strong, you might consider it a form of infidelity. Let's hope you can keep your wits about you. This is your relationship at risk here, not mine. Come on you little cupcake. Let's demo.
This demo. is the one about the error handling I mentioned earlier. As you can see in the Gif., the method doesn't have any error handling code. But, the console program displays an error message to the user. Yes, you're right. It's brilliant.
This next demo. is where everything changes, though. I hope you've strapped your pants on tight.
In a moment as clear as crystal, what you’re looking at is a self-documenting "help" section. This means you no longer need to write a help guide -- from scratch -- in every console program. You can now add Waterworks custom attributes to the methods you want to declare at run-time. Console.Waterworks will make a note of those attributes and display them like the demo. shows.
Everything above is brilliant and has a place on this Earth and you know this. Like I said before, you're not an idiot. So, the next time you're writing a console program, don't forget to add Console.Waterworks to your solution.
For more information about using Console.Waterworks in your solution, head to the GitHub. Console.Waterworks is available as a .Net and .Net Core NuGet package.
Thank you for your time and I look forward to your words of recommendation about me reach me. And, when I say "reach me", I don't me via you. I mean via other people talking about you and on your behalf.
Thanks again.

14
TestCentre/txt Files/desktop-clock-info.txt

@ -0,0 +1,14 @@
About Desktop Clock
This is a basic WPF program which displays the data and time so it is readable from a distance. Desktop Clock uses a NuGet package called This allows the program to look like a Windows 10 UWP program. The most notable aspects being the translucent chrome and the highlighting of near-by buttons.
Screenshot 1 Desktop Clock is a WPF program which looks like a UWP program.Publishing Information
If you would like to use, it you will need to build from the source code provided. I did not want to mess around with ClickOnce or any other packaging mechanism.
With it being a WPF program, it can run on Windows 7 and 8 machines.
Future Plans
I do not intend to take this any further. It is a simple program which I have running 247, floating about on the screen. It sits there and does what I need it to do. Anything else seems like overkill and I do not find myself wanting it to do something extra. Therefore, if you want something adding to it, I recommend you fork it.
GitHub
Desktop Clock is  available on GitHub. Feel free to check it out, download it or fork it

8
TestCentre/txt Files/word-generator.txt

@ -0,0 +1,8 @@
Are you the type of person who hates work? Are you someone who resents the fact you're born into a system not of your choosing? Are your teachers lazy, dismissive and not interested in your education? We're looking at you Mr.Heath... Then you need Word Generator. The app for students with a deadline.
Imagine you're at home and finishing off your English essay for Mr. Dillbank. A teacher who is always drunk and has been struggling to put a sentence together since 2014. He never used to be this way but Maureen had to leave him for Derek, the Head of Music at Barnworth High. He isn't even good looking. He looks like an orange balloon with pigeon droppings for a moustache. Who, in the history of mankind, thought that was a good look? No one! That's who! Screw you Derek! Screw you! You're fooling no one with that hair piece...
...
Sorry... I got a little side-tracked there....
Anyway, where was I...
So, you're finishing your essay and you realise your word count is lower than the expected one. Two-hundred words short, as a matter of fact. This is infuriating because you're supposed to be playing football in twenty minutes. You don't have enough time to add two-hundred words and be ready in time for football. What do you do? You open Word Generator of course. You add the extra words in a few clicks and your already off to football, with time to spare. Your mum only checks the word count these days and Mr. Dillbank hasn't seen straight for years. They think you have done your homework and you get to play football. Everyone is a winner here, apart from you in the long term but that's ok. It's not ok but it feels ok and that's what counts right now.
So, you're sold. You're in and wanting to know more. How does it work? I'm glad you asked. It uses the latest in space-age technology. Word Generator utilises the Markov Chain algorithm. When you boot Word Generator up, feed it a plain text (.txt) file and specify what Markov Value you want to use. Using that information, it spits out text that resembles the original text. This helps hide the deception.
Just in case you're wondering, the Markov Value is a number. For the app it's a number between one and ten. The higher the number the closer the generated text will resemble the original text. For example, a value of one will generate non-sense and ten will spit out like-for-like text. If you're feeling confident, I recommend you turn it up to five and see if teachers like Mr. Dillbank notices.
Loading…
Cancel
Save