Setting up VM (Virtual Machine) with Visual Studio 14

Hi Friends,

In today’s discussion, I’ll show you how to set up a VM. A VM is nothing but an image of original machine what we use on daily basis. So, while configuring the same, you will select the machine configuration like Cores and Memory apart from the inbuilt software which you are installing. Below i have jotted down the steps, how to setup a VM for installing Visual Studio 14.

Since, I have an Azure subscription, so let me go ahead and create one Custom VM for me. So, let’s go ahead and login into http://azure.microsoft.com/en-us/ . Once you logged in successfully, you will land in dashboard page as shown below in the screen shot.

551th

So, here as you can see in the left menu bar, I have already created one VM with Visual Studio 14. But, let me go ahead and show you the steps at least how to create the same. This is very simple, you need to click on Virtual Machines link in the menu and then click on “New” button at the bottom of the page as shown below.

552nd

Now, as soon as you create on New button, it will open a new page with different options as shown below

553th

Then, I’ll select create a VM “From Gallery”. Then, this will again list me further options as shown below

554th

Now, it listed me many options with which I can go ahead and create my Virtual Machine. However, in here I’ll be selecting Visual Studio from the left pane as highlighted. Upon clicking on this, it will give me Visual Studio 14 option as shown below in the screen shot.

555th

Now, when I click on next, then it will ask me usual details like username and password and some other details like VM configuration related stuffs as shown below in the screen shot.

556th

Now, since I have already created my VM, so I’ll close this here itself and login to my VM itself. In order to connect to the VM, you need to dashboard page, select the VM and then from the bottom of the page say connect as shown below in the screen shot.

557th

Now, as soon as you click on this icon, it will download a utility to connect you to your remote machine. So, here this utility will ask for your username and password which you have provided by creating the VM. Upon Successful authentication, it will launch the Virtual Machine as shown below in the screen shot.

558th

Now, here when you click on the desktop icon, it will show Visual Studio Icon on the desktop itself as shown below in the screen shot.

559th

So, with these many steps we have successfully configured our VM with Visual Studio installed. Now, to know more in depth for the upcoming version MVC 6, refer my book which is scheduled to be launched in few weeks of time. Till then stay tuned and Happy Coding.

Thanks,
Rahul

1,087 total views, 1 views today

MVC 6

Hi Friends,

I was just trying my hands with recently launched CTP version of Visual Studio 14, which is featuring MVC 6 scheduled to launch next year. Changes in MVC 6 are pretty awesome. Some of the cool things which i liked it’s Roslyn compilation, which makes MVC experience much more Agile. What i mean to say, you save your changes in the controller and just refresh the same in the browser, it will take effect without building the solution again. Now, there are many more exciting stuffs of MVC 6 which i’ll discuss in coming days. But, for now if you want to do some hands on with MVC 6, don’t install VS 14 on your working machine, because your existing VS may start behaving weirdly. How, i did this, i configured one VM for me on Azure with Visual Studio 14  and there i did all the experiments.

While doing the same, i hosted the site on Azure as well just for fun. It can be navigated from “http://rahulmvc6.azurewebsites.net/“. Till then stay tuned and happy coding.

Thanks,
Rahul
Happy Coding

839 total views, no views today

Automated Testing Part – 2

Hi Friends,

Now in today’s discussion, we’ll discuss all these things deeply with a demo. So, let me go ahead and create one new class library project as shown below.

1st

Now, I’ll add NUnit Reference in here 1st from Nuget package manager as shown below.

2nd

Now, once it gets successfully installed, you can verify the same in references as well as shown below.

3rd

So, now we are good to start our testing as all required prerequisites installed successfully. So, now let’s go ahead and create our 1st test class. But before that let’s write a sample class which we want to test. So, below i have created one sample class with the name “Account

12th

Now, thats a very basic class which is keeping track of your account with balance amount. So, the same class we are going to test here with our new test class as shown below.

7th

so, as you can see in the above screen shot i have annotated this test class with [TestFixture] to tell the compiler that treat this class as a test class and then I have also annotated the test method with [Test] attribute. Now, in this Test method, 1st thing is arrangement where in you will be calling the APIs of that class which you want to test, so for that 1st you need create one instance of that class. Once that is done, in the Act section i have called “DepositAmount” method with amount 20000. Then in the last section i have done the assertion with the amount which i have deposited.

Now, in order to run the Unit test, what you can do is right-click the test method and say “Run Unit Tests” as shown below in the screen shot.

8th

Now, as soon as you do the same, it will open the test window with the following results as shown below in the screen shot.

9th

so, here in the screen shot it is clearly indicating that test is passed. Now, let’s try to fail this test by just changing the Assertion statement over here.

10th

Now, when i try to run the test, then it will fail.

11th

Likewise we can test various edge cases. So, with this i am wrapping this session here itself. In the next session, we’ll try to test some more practical test cases based on the class. Till then stay tuned and Happy Coding.

Thanks,
Rahul

685 total views, no views today

Automated Testing Part – 1

Hi Friends,

Today, in this discussion, we’ll discuss more about testing rather we’ll delve in automated testing and understand why it is mandatory for software development process. If you are following AGILE model in software development, then you might be knowing that client always focuses on testing of existing features plus the new features which is getting developed. Writing good test cases and meaningful test cases which are covering your code end to end gives you confidence that you have written robust code which won’t fail in any circumstances. Now, let’s understand some of the strengths of the Automated Testing.

  • You can run these test cases any time
  • Very quick while running
  • You can run them again and again
  • Also it relies on logical assertions.

Now, Let’s look at the different type of Tests.

  • Unit Test:- Unit Tests are about testing your logic in small chunks rather testing your logic in isolation.
  • Integration Test:- Means testing things together.
  • User Interface Tests:- So, these tests execute via UI and testing things at user like behavior of the application when load increases likewise.

So, now without wasting time, let’s begin our discussion with Unit Testing:- So, as I said that Unit Testing is all about testing the thing in isolation. So, basically unit test focuses on the behavior of class like how it will be utilized by other classes. So, it makes one thing very clear that we’ll test only public API, we won’t test private methods. So, private methods or behaviors will be tested via public class members once it is exposed to it. So, ideally unit testing is best for testing complex and detailed behavior. Now, it also help us to catch the defect at the lowest level itself. Now, let’s check few best practices of writing Unit Tests.

  • Testing Boundary Values:- Obviously, whichever testing book you refer, they will stretch upon this point.
  • Happy Path and Negative Test cases:- Write test cases for both scenarios and test them equally.
  • Find a bug and Write test case to fix the same.
  • Write Test cases to test almost every part of your code

Now, basically Tests are divided into 3 fundamental Units. They are:-

  • Arrange:- Under this we basically create an instance of class being tested. If it requires any kind of initialization, we’ll also do it here.
  • Act:- In this stage, we will call the functionality which we are interested in testing.
  • Assert:- In this phase, we basically compare our outcomes with expected behavior, based on the outcome, we come on conclusion whether test passed or failed.

Testing Frameworks:-

Now, Testing Frameworks basically provide a platform to write your tests, organize them, then provides the ability to do assertions on the test result. So, the test code which we write will use this framework and use testing attributes and assertion methods. Now, associated to this, there is one more concept which is closely related, often designated as “Test Runners“. So, a test runner will understand the framework being used, it will locate, enumerate and run tests for us. It will also give the snapshot of these tests in different flavors.  Below i have mentioned few of the available Testing framework under Microsoft ecosystem:-

  • MSTest
  • xUnit.Net
  • NUnit

Now, below is the screen shot for the same which is having the reference for testing framework in my solution. Now, here i will be using Microsoft Testing Framework for running my tests.

1st

I’m wrapping this session here itself. In the next session we’ll start doing Demo with test classes and Test Methods. So, till then stay tuned and happy coding.

Thanks,
Rahul
Happy Coding

739 total views, no views today