Learn how to look at the Visual Studio solution containing three projects. Look at the Unit Test project where the test code will go. Look at the Class Library project where the data reading code will go. Finally, look at the Windows Presentation Foundation Project where the XAML and related visualization code will go.
- [Instructor] Let's talk a look at the Visual Studio solution, which we'll use as our starting point. Included in the exercise files there will be a WeatherData solution. Look for the begin folder which will be the starting point and open the WeatherData solution. We are using Visual Studio 2017, in this case the Community edition. To confirm click on help, and about Microsoft Visual Studio, but Visual Studio Community edition, Professional edition or Enterprise edition would work.
Unfortunately this solution will not open in Visual Studio Code because of the project types we're using. Take a look at the far right, in the Solution Explorer, but if it's not showing click on view, Solution Explorer. And under Solution Explorer you should see three projects. The first one is the LiveCharts WeatherData project. This is a Wpf project and this is one of the reasons we need Visual Studio Community edition, so that we can edit this project type. Later on we will go an modify the main window to add the control that we will use to draw the graph, and here we have a class library project which is where we will write most of our code for retrieving, parsing and manipulating the data.
But as we make progress, we will test our progress in a unit test project called Tests_WeatherData. Now instead of running our project as a starting project or as a StartUp Project like Visual Studio calls it, you can see here I will right-click on LiveCharts WeatherData, right-click, set as StartUp Project. That's fine for when we want to run the Wpf application at the end. While we are writing our unit test code, you'll see here in Tests_WeatherData.cs, double-click, we have unit tests pre-created and for the first one I've already written the code for you and as you scroll down you'll see we have more work to do.
And as we work through these unit tests, we will run them one at a time from the Test Explorer menu. If yours is not showing click on the Test menu, then Windows and Test Explorer. And then you'll see at the top left here, we have each of the unit tests shown, you can select and right-click, and then run the selected tests. And so that's how we'll iteratively go through each of our unit tests by adding code anywhere you see a to-do comment or a not implemented exception. Let's go back to the source code, so here in the Tests_WeatherData file, notice on the first unit test here where it is says ParseLine, just below it has line 30 where a piece of code is being executed, and then we want to check that the result is what we expect.
Now instead of using the traditional assert statement, here on line 32 and 33, you see a check statement. This is from the library called NFluent, notice here on row number four we have the Nfluent name space, and from there we can then write very readable check statements like these. Back on line 32 we say check that, the weather object TimeStamp value is equal to a value that we provide. And so it just makes for a very readable, a fluent if you will, way of evaluating the results of your unit tests.
So in addition to Nfluent, there is of course the two libraries that's most important for accomplishing our tasks. Right-click on the Solution and select Manage NuGet Packages, and you'll see under the Installed tab, here at the top it says Installed, we have LiveCharts.Wpf and we have MathNet.Numerics. These are the two that we're added to do A, the math, so that we can find out the slope of our data, and then B, the second part, in Wpf we want to draw a graph and actually visualize our data.
When you open your Solution the first time, you will need internet access so that NuGet can actually fetch the necessary dependencies for you. I'll close this window, and close the source code. And press control shift B, cause the Build to run, and if all is well with the NuGet Packages, the SetUp, all your permissions on the file system and so forth, then you should have three successfully built projects. And now you're ready to start writing code with me.