Course Home | Official Visual Studio Docs
While they’re other IDEs available for developing in CSharp (C#) the defacto and go to IDE is Visual Studio. Visual Studio is supported on all OS now, however, this guide is going to use screenshots/gifs of the Visual Studio IDE for Mac. If you’re on Windows, don’t worry, the flow will be 99% the same, so I’m sure you’ll have no problems at all following along.
So you need to head over to https://visualstudio.com and click Download under the Visual Studio IDE on the home page. Then just follow the installation wizard. For this course you can deselect any additional options such as iOS/Android support and so forth, we won’t be using those.
Majority of people who share code online and at workshops tend to store their code in GitHub. So it’s certainly a site worth getting familiar with. As is git itself for that matter. Here is a great online tutorial for learning git, claims to take 15 mins.
With regard to my lessons, you just need to go the URL provided with the lesson and click ‘Download Zip’ from the green button. Then unzip somewhere.
It’s very simple to create a new solution, File > New Solution. This will open a dialogue that may initially look confusing. Visual Studio will list a lot of templates projects for various things you may want to code. However, for the majority of automation projects, your going to want a ‘.NET Class Library’ project. You have to create at least one project at the time of creating a new solution. On a Mac, you’ll find this option under ‘Other > .NET > Library’. Click next.
Then you just need to give your solution a name such as ‘Learning-CSharp’ and give your first project a name such as ‘the-basics-of-csharp’. Testing related names could be ‘FriendlyTesting-Automated-Checks’ and the first project could be called ‘UI-Checks’.
Visual Studio makes it nice and easy to share code, as projects are wrapped in a higher level called a Solution. A solution can contain many projects. There is also a tool called NuGet, which is the C# equivalent of Maven. We can use NuGet to find and manage the dependencies of our projects.
However for this course, you’ll just need to download from the GitHub provided at the top of the lesson, unzip it. Open Visual Studio and go to File > Open and navigate to the downloaded code and select the .sln file. This will open the solution and all the containing projects.
The easiest way to build your C# project is to go to Build in the top menu nav and click ‘Build All’. This will build your entire solution, if it’s successful you’ll see a ‘Build Successful’ message at the top of the IDE. You’ll also see that you can build an individual project in the same menu.
The first to be aware of is the Solutions window. This is where we can see all our projects and the files within those projects. It’s basically a file explorer.
The easiest way to run a check is to navigate to the ‘Unit Tests’ pad. Pad? Yeah, on Visual Studio for Mac, windows are called pads. On Windows, this view is still called Test Explorer, and I believe it can be found on View > Toolbars.
Then all you need to do is find the check you want to run and double-click it. That will open the Test Results window on a mac where you can see the results, on Windows I believe you stay in the Test Explorer.
Comments