Showing posts with label Visual Studio 2010. Show all posts
Showing posts with label Visual Studio 2010. Show all posts

Saturday, January 22, 2011

ASP.NET MVC 3 Project with NUnit as Testing framework

[UPDATE] Marcus has been able to make a new Visual Studio Extension that add NUnit as an option when selecting test framework for ASP.NET MVC 3. You can get that from Visual Studio gallery for free.

Don’t you sometimes have this feeling when you need something that Microsoft could make out of the box?

I got the same kind of idea today when I was trying to create a new ASP.NET MVC 3 website with NUnit as test framework. And I could find this page How to: Add a Custom ASP.NET MVC Test Framework in Visual Studio but the whole thing wasn’t very easy and it was indicated that you should insert some keys and values into registry.

“Man, I don’t like that”, I thought, “Isn’t there an easier solution which could make it all work ?”.

I googled a little bit, and I found this blog post: ASP.NET MVC 3 with NUnit Testproject written by Marcus Kimpenhaus. In the bottom of this blog post there is a link via which you can download and install the NUnit template for ASP.NET MVC 3, this template worked for x64 bit machines, but I left a comment and he was nice to update it for x86 machines too. Thanks very much Marcus this project template is invaluable when need it. I also suggested to publish this template to NuGet feed, and if this will work it would be great and you could install it directly from your NuGet console.

So let’s resume what do you need to do in order to have a NUnit Test project template for your ASP.NET MVC 3 project:

  1. At the bottom of the blog post click the download link for the project template
  2. Run install.bat as administrator, now this bat will check the type of your machine : x64 or x86 and will edit registry accordingly to that, it will also update your Visual Studio 2010 cache so please wait a little bit there
  3. Go and thank Marcus for his work, and send a mail to ASP.NET team to include this project template in the Visual Studio SP1. After all the SP1 is coming in spring so they still have lots of time to include it.

Hope this will help someone.

Wednesday, October 20, 2010

Tools I can’t imagine my dev life without #2: XSLT Debugger in Visual Studio

Hi,

While a lot of us .NET developers at some point in our life used XSLT, it was never easy. Of course our logic and XSLT syntax should help us to understand different things but that is not always the case. Probably because it’s almost always a black box abstraction.

In my last project we use a lot of XSLT for generating all kind of documents with all kind of restrictions and filtering, usually you have an XML document, you got an XSLT and a XslCompiledTransform object which you use to actually get your transformed document. But because of the thing that it is like a black box all you can do is sit back and hope you did well the XSLT thing and you’ll get needed document out of the box. At least this is what I thought until this week.

This week I needed to change one of my XSLT document templates, because I was getting a very strange error at document generation. I thought at this moment that I couldn’t do it without debugging and I was hoping that somewhere in the world existed a nice tool which could manage XSLT debugging and which would have at least a trial period. I googled “debug XSLT”, and guess what I found? This link which gave me the power I didn’t even imagined to have without having to install some third-party tools.

It is incorporated directly in Visual Studio !!! I tried it in VS 2008 and VS 2010, Visual Studio 2010 even got a profiler for XSLT, so you could measure your transformation sheets and make reports on that. Isn’t that great? Plus you got a lot of way to do debugging. And now some screenshots.

DebugXslt

1. While stylesheet open click on XML => Debug Xslt

ChooseXml

2. Choose input XML file

Debugging

3. Debug and actually see the magic ! In parallel you can see the output.

Same things could be done in VS 2010

Visual Studio 2010

And you automatically get the html output. Plus you can always see the source of html.

So get ready to a new era of XSLT debugging with all the tools you are used to: Locals, Watches, Immediate Window and others as well.

Link for Download

Friday, February 26, 2010

.NET 4.0 : Complex Numbers

 

    Hello today I’m going to start to describe and apply the new classes which were added into .NET 4.0 Framework.

 

When I was 16, it always was a problem there. Sex was in the air, a lot of different opportunities had the habit to rise without any prevention at all, and I was loving challenges. BUT, it also was the period when the most useless and useful information was taken in and out from the classes. Physics, mathematics, chemistry and others were at the same time boring and challenging.

One of the basic subjects in math was : Quadratic equations, and also introduction of complex numbers, which was pretty strange… imaginary and real parts formed the complex number. But these numbers has a lot applications in physics, astronomy and geometry.

Question how did we solved these kind of equations in the past?
We did a structure or a class and tried different things with it, like multiplication and division, and others as well. But sometimes we didn’t really figured out very well the logic.

Now, guess what, in .NET 4.0 we already got a Complex structure, which in fact represents the complex number.

So here is a very simple application of it:

using System;
using System.Numerics;

namespace Intro.ComplexNumbers
{
    class Program
    {

        static void Main(string[] args)
        {
            // do it always, we'll stop the loop by pressing Ctrl + C.
            while (true)
            {
                string errorMsg = string.Empty;

                Console.WriteLine("To solve the quadratic equations using the Quadratic Formula,");

                int a = ReadCoeficientValueFromConsole("a", "Please enter ax^2: ", ref errorMsg);

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    ShowErrorMessage(errorMsg);
                    break;    
                }

                int b = ReadCoeficientValueFromConsole("b", "Please enter bx: ", ref errorMsg);

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    ShowErrorMessage(errorMsg);
                    break;
                }

                int c = ReadCoeficientValueFromConsole("c", "Please enter c: ", ref errorMsg);

                if (!string.IsNullOrEmpty(errorMsg))
                {
                    ShowErrorMessage(errorMsg);
                    break;
                }

                // we're assuming that the discriminant is negative
                // for more information visit http://en.wikipedia.org/wiki/Quadratic_Formula#Quadratic_formula
                Complex root1 = new Complex(-b / 2 * a, Math.Sqrt(4 * a * c - b * b) / 2 * a);
                Complex root2 = new Complex(-b / 2 * a, (-1) * Math.Sqrt(4 * a * c - b * b) / 2 * a);

                Console.WriteLine("Roots are: ");
                Console.WriteLine("Root1 (positive): {0}", root1);
                Console.WriteLine("Root2 (negative): {0}", root2);
            }
        }

        /// 
        /// Shows error message in console.
        /// 
        /// Error message.
        private static void ShowErrorMessage(string errorMsg)
        {
            Console.WriteLine(errorMsg);
            Console.ReadKey();
        }

        /// 
        /// Reads a string from console and tries to convert it into an Int32, and assign it 
        /// to a coefficient.
        /// 
        /// Coefficient name.
        /// String which will be shown to ask the coefficient introduction.
        /// The coefficient Int32 value.
        private static int ReadCoeficientValueFromConsole(string coefficientName, string requieringString, ref string errorMsg)
        {
            int coeficient = 0;

            Console.WriteLine(requieringString);

            string aValue = Console.ReadLine();
            if (!string.IsNullOrEmpty(aValue))
            {
                try
                {
                    coeficient = Convert.ToInt32(aValue);
                }
                catch (FormatException)
                {
                    errorMsg = "Your '" + coefficientName + "' coeficient is not a numeric value.";
                }
                catch (Exception)
                {
                    errorMsg = "There was an exception raised because of coeficient '" + coefficientName + "'";
                }
            }

            return coeficient;
        }
    }
}

Here are some screenshots:

Figure 1. Coefficient error

Figure 2. Good coefficients solving 3x2 + 9x +7 = 0

Download source from here

NOTE: I’ve done this project using Visual Studio 2010 RC.

Wednesday, February 24, 2010

What’s going to blow our mind in 2010 ?

Hi guys, now a little time passed, half of the year while I'm semi-actively posting here.

We took a step back and tried to write about things which could matters. And which isn’t really discussed by anyone else.

I really tried to make it better, although I hope that this year I’m gonna obtain my goal of writing at least once per week.

So what is going to blow our mind ?

 

I will be writing about:

  • Udevi community
  • F# 2.0
  • Visual Studio 2010
  • ASP.NET MVC 2.0
  • .NET 4.0
  • JQuery
  • Open source projects in which I’ll be participating
  • Tips and tricks

Hope you will like it !

Friday, October 23, 2009

Windows 7 officially released today + Visual Studio 2010 Beta 2 is available

 

Windows 7

 

Hi,

since the Vista “nightmare” begun, the end-users, Microsoft customers and general client in software development had fear passing multimillion companies to Vista, and after all why XP is bad? What made Vista so bug full ?

The answer is evident. In windows Vista Microsoft tried to do something very different that they were doing before. With the power of WPF, and a lot of other new features for Windows, as Sidebar for example with all those gadgets, came the possibility to make bugs, because then people try something new, at first it is not really an ideal thing.

That is why most costumers continued to stay on XP and Microsoft was obliged in a way to make the SP3 for Windows XP. At the same time another team was working on Windows Vista SP1, which eliminated most problems. But these people seem to forget that we had 3 Service packs for XP and the original version was far from ideal too.

But as clients were already disappointed they were actively refusing to accept Vista as a default OS on their computers, and Microsoft in a year started to develop the new brand Windows 7, which was labeled lately Windows Heaven. :)

Windows 7 in comparison with Vista and even XP SP3 is:

Faster loading, more responsive, more intuitive and much more compatible + ideal on 64 bits machines. You will fall in love with this OS, and I think it is the release which will make people forget about Vista, and try to create with it better quality software. Anyway the future year will show us all the improvements that can be done on Windows 7, because nothing is really ideal. 

And it is already released today! So from now on I will also be publishing tips for Windows 7. Hope that you will grab your copy in next months. And by the way here is the link for the requirements for Windows 7.

Visual Studio 2010 Beta 2

While a lot of us, .NET developers still try to learn all the features from the framework and .NET 3.5 in general, because as one man said

Framework big, brain small :)

.NET 4.0 is coming out, which a whole new bunch of features and possibilities and a new IDE: Visual Studio 2010 is coming out and bringing with it a lot of goodies. And first what I appreciated was the new look of Visual Studio

The new design plus a lot of different new features of Visual Studio 2010, I won’t describe them but I will give you the starting points

So go and check Visual Studio 2010 Beta 2 right now, because the RTM is announced on March 22, 2010. And we’ll have some time to play with Beta 2.