Friday, February 13, 2015

Using Jasmine with Visual Studio

Jasmine Overview

Jasmine is a JavaScript unit testing framework similar to MS Test or NUnit.  Jasmine requires four references to get it to work:
  • Jasmine.js
  • Jasmine-html.js
  • Jasmine.css
  • boot.js
Let's test the following JavaScript:

function ExtractNumbers(text) {
    if (!text)
        return text;
    
    return text.replace( /\D+/g, '');
}

Here is the test that you would write in Jasmine:

describe("Common tests", function() {

    it("ExtractNumbers method should extract numbers from a string", function () {
        expect(ExtractNumbers("Logan 5, Francis 7")).toBe("57");
    });

});

I have created a JSFiddle to demonstrate:

Using Jasmine with Visual Studio and MS Test


Follow these steps to create a Jasmine project with Visual Studio:
1.  Create a blank web project (not a class library like you would do for MS Test or NUnit)
2.  Create a similar folder structure for the JavaScript files you wish to test.
3.  Add the JavaScript files as links in your project
4.  You will need to manually download Jasmine from GitHub and put the files in the Scripts folder since there is no recent Nuget package.
5.  Under Tools -> Extensions and updates, Visual Studio Gallery.  Search and Install Chutzpah Test Adapter for the Test Explorer which is a JavaScript test runner for Visual Studio.  Also install Chutzpah Test Runner Context Menu Extension.  Chutzpah works with QUnit, Jasmine, and Mocha testing frameworks.
6.  Add a JavaScript file that will be used for the tests.  Add a reference at the top to the JavaScript file you wish to test by simply dragging and dropping the file to the top.  Here is an example:

/// <reference path="../../UI/Scripts/Common.js" />

describe("Common tests", function() {

    it("ExtractNumbers method should extract numbers from a string", function () {
        expect(ExtractNumbers("Logan 5, Francis 7")).toBe("57");
    });

});

Using Jasmine with Resharper

Follow the same steps above for Resharper except Chutzpah is not required for Resharper.  Resharper works out of the box with QUnit and Jasmine to run JavaScript tests.

Wednesday, February 11, 2015

Using QUnit with Visual Studio

QUnit Overview


QUnit is a JavaScript unit testing framework similar to MS Test or NUnit.  In order for QUnit to work, you need a reference to QUnit.js and also a QUnit.css file.

Given the following JavaScript:

function ExtractNumbers(text) {
    if (!text)
        return text;
    
    return text.replace( /\D+/g, '');
}

Here is a corresponding QUnit test:

QUnit.test( "ExtractNumbers", function( assert ) {
  assert.equal( ExtractNumbers("Logan 5, Francis 7"), "57", "Passed!" );
});

I have created a JSFiddle to demonstrate:
http://jsfiddle.net/gfinzer/tmdn2nfj/6/


Using QUnit with Visual Studio and MS Test

Follow these steps to create a QUnit project with Visual Studio:
1.  Create a blank web project (not a class library like you would do for MS Test or NUnit)
2.  Create a similar folder structure for the JavaScript files you wish to test.
3.  Add the JavaScript files as links in your project
4.  Add a NuGet package reference to QUnit
5.  Under Tools -> Extensions and updates, Visual Studio Gallery.  Search and Install Chutzpah Test Adapter for the Test Explorer which is a JavaScript test runner for Visual Studio.  Also install Chutzpah Test Runner Context Menu Extension.  Chutzpah works with QUnit, Jasmine, and Mocha testing frameworks.
6.  Add a JavaScript file that will be used for the tests.  Add a reference at the top to the JavaScript file you wish to test by simply dragging and dropping the file to the top.  Here is an example:

/// <reference path="../../UI/Scripts/Common.js" />

QUnit.test("ExtractNumbers", function (assert) {
    assert.equal(ExtractNumbers("Logan 5, Francis 7"), "57", "Passed!");

});

Using QUnit with Resharper

Follow the same steps above for Resharper except Chutzpah is not required for Resharper.  Resharper works out of the box with QUnit and Jasmine to run JavaScript tests.


Tuesday, January 6, 2015

Developer Conferences for 2015

Here is the list of developer conferences for the Midwest and the major U.S. national conferences.  If you would like your conference listed.  Please contact me and I will add it.

CodeMash V2.0.1.5

Jaunary 6-9, Sandusky, Ohio
Conference Only – Thursday and Friday: $300
Conference + Single Precompiler – Wednesday through Friday: $450
Conference + Double Precompiler – Tuesday through Friday: $600
http://codemash.org/


KalamazooX

March 14, Kalamazoo, Michigan
Price $50
http://kalamazoox.org/

 

CocoaConf

March 27-28, Chicago, IL
Conference Only:  $550
Conference + Workshop:  $700
http://cocoaconf.com

Code PaLOUsa

Pricing:  $50
April 27-30, Louisville, KY, USA
http://www.codepalousa.com/


Visual Studio Live

March 16-20, 2015, Las Vegas, Nevada
June 1-4, 2015, Austin, TX
June 15-18, 2015, San Fransisco, CA
August 10-14, Redmond, WA
September 28-Oct 1, Brooklyn, NY
November 16-20, Orlando, FL
http://vslive.com

Build 2015

April 29-May 1, 2015, San Francisco, CA
Previous Pricing for 2014:  $2095
http://www.buildwindows.com/

StirTrek

Price $75
May 1, 2015, Columbus, Ohio
http://www.stirtrek.com/

Microsoft Ignite

May 4-8, Chicago, IL
Expo Only Pass:  $300
Day Pass:  $500
Full Conference Pass $2,220
http://ignite.microsoft.com

GoTo Conference

Pricing $950 to $2700 depending upon when you register and how many workshop days
May 11-12, Chicago IL
http://gotocon.com/chicago-2015/

 

Dev Intersection

Pricing $1595 to $2942 depending upon when you register and how many pre-conference days
May 18-24, Scottsdale, AZ
http://devintersection.com

 

QCon

June 8-12 New York, NY
Price $1500 to $2300 depending upon how early you register
https://qconnewyork.com/

 

PyOhio

Free
http://www.pyohio.org/

Codestock 2015

Sometime in July, Knoxville, Tennessee
No Pricing Announced Yet:  ~$100
http://www.codestock.org/

Agile 2015

August 3-7, Washington DC
Price $1999
http://agile2015.agilealliance.org/

That Conference

August 10-12, 2015, Wisconsin Dells, WI
No price announced this year.  Last years price was: $349
Tickets go on sale starting May 13, 2015 at 8:10am!
http://www.thatconference.com/

devLink

Sometime in August, Chattanooga, Tennessee
No price announced this year.  Last years price was: $~100 to ~200
http://www.devlink.net/

Midwest Tech Fest (formerly Central Ohio Day of .NET)

Early Fall, Columbus, Ohio
No price announced this year.  Last years price was: $0 to $10
http://mwtechfest.com/
https://www.facebook.com/MidWestTechFest
https://twitter.com/MidwestTechFest

Dev Connections

September 14-17, Las Vegas, NV
Essentials:  $1299
All Access :  $2099
http://www.devconnections.com/

 

CloudDevelop

Sometime in October, Columbus, Ohio
No price announced this year.  Last years price was: $20
http://clouddevelop.org/

Columbus Code Camp

Sometime in October, Columbus, Ohio
Free
http://columbuscodecamp.com/

 

M3 Mobile Conference

Sometime in November, Columbus, Ohio
No price announced this year.  Last years price was: $125 -$250
http://www.m3conf.com

 

St Louis Day of .NET

Sometime in November, Columbus, Ohio
No price announced this year.  Last years price was: $300
http://stldodn.com


Dog Food Conference

Sometime in November, Columbus, OH
No price announced yet.  Last year was $50
http://www.dogfoodcon.com

Free PluralSite Subscription with MSDN

Microsoft has announced a free subscription to PluralSite with MSDN.  It includes 30 courses.  After signing up, you can upgrade for a full subscription for 15% off.

Use this link:
https://msdn.microsoft.com/subscriptions/pluralsight30

Here are the courses included:

Applied Windows Azure
Architecting Applications for the Real World in .NET
ASP.NET MVC 5 Fundamentals
Asynchronous C# 5.0
Building a Site with Bootstrap, AngularJS, ASP.NET, EF and Azure
Building an Intelligent System: From Embedded to Cloud
Building Web Apps & Services with Entity Framework and Web API
C# Generics
Defensive Coding in C#
Enterprise WPF with XAML and C# from Scratch
Getting Started With Release Management for Visual Studio 2013
Hack-proofing Your ASP.NET Web Applications
IntelliTrace
Introduction to Visual Studio 2013 - Part 1
Introduction to Visual Studio 2013 - Part 2
Lessons from Real World .NET Code Reviews
Mastering Visual Studio 2013
Microsoft Fakes Fundamentals
Microsoft Test Manager 2013
Migrating Internet Applications to Azure
Mobilize Your ASP.NET Web Forms
Plan, Create, and Deploy to Azure With Visual Studio Online
Real World Scrum With Team Foundation Server 2013
Security and Encryption in SQL Server 2012 and 2014
SharePoint 2013 Fundamentals
Team Foundation Server 2013 New Features
VB.NET Fundamentals
Visual Studio Data Tools for Developers
Visual Studio LightSwitch 2012 and 2013
Windows Azure Infrastructure as a Service Essentials

Wednesday, August 13, 2014

Running Software with No Admin Rights

Sometimes you are given a machine where you don't have local admin rights.  While it is understandable to lock down PCs to prevent viruses and licensing issues it can greatly hinder work.  The PortableApps platform gives you the ability to run the applications that you need without installing anything or violating any license agreements.  All the programs are free. 

Here are some great free developer tools that run on the Portable Apps Platform
Notepad++
SharpDevelop
Paint.Net
PicPick (This is like Snag It)
Filezilla
Chrome
Firefox
Zim Desktop Wiki
Expresso
WinMerge
Database Browser
Baretail
Skype
TweetDeck
ILSpy
ImgBurn
CamStudio
7Zip
Team Viewer

These are commercial programs that have Portable App Versions or can be run from the Portable Apps menu.
Beyond Compare
Directory Opus
RazorSQL
RoboForm

Tuesday, May 6, 2014

Pointing out an awesome developer tool

At StirTrek I found out about an awesome developer tool that I would like to point out.

I had the privilege of hearing about it directly from Anthony vander Hoorn which is one of the creators of Glimpse.  Glimpse is a tool for debugging your ASP.NET MVC or ASP.NET Web Forms site from a high level.  It has two major features:

1.  It tracks all the requests for a page from the GUI all the way to the back end.  It has tabs for the different layers.
2.  It describes all the environment information.  At nearly all the clients that I have worked for, the developer has access to the development site.  However for QA and Production Sites, usually a systems administrator group has full access and developers have no access.  Did everything get deployed correctly with your 1057 step deployment script?  Really you don't know for sure.  Glimpse helps answer that question.  It also helps with targeting which layer has performance issues from the GUI all the way to the back end.

After seeing it in action and talking to some of my developer friends, it seems that I have been living in a cave.  Glimpse is something every developer should know about.

  The Glimpse Core is available on NuGet.  There are also 67 plug ins for the tool.

Wednesday, April 2, 2014

A Crash Course in Responsive Design



Preface

I am presenting this material, not as an expert of responsive design or even in CSS, but simply as a person that has gone through it once.  The main goal is to have a simple tutorial that will be useful to you.  Although I have worked with all layers from the User Interface to the Database Layer; I have always considered myself a back end developer.  This thinking primarily stems from my poor graphical ability.  If I drew you a stick figure, you might have a problem distinguishing what it is.  My handwriting has the readability of Egyptian hieroglyphics.   :)  Despite my shortcomings, this year I have tried my hardest to step into front end design.  Normally I have been on large enterprise application teams with super complex back ends.  That is where I usually thrive.  The user interface didn’t need to be anything but battleship gray because it was used internally with one browser type.  Additionally, we would have a person that would be half graphic designer and half front end CSS designer.  The front end designer would create the graphics, the colors, the CSS sheets, and the rest of the developers would simply use the styles and images that were created.  Things have changed drastically for the web in recent years.  Businesses and users are demanding rich responsive web designs.  If you don’t know responsive design, now is the time to learn it.  All my dress socks are black for a reason.  If I can do this, certainly any developer can do it.  I take that back, I do have one pair of green socks.  The color combinations are always exciting if I accidentally put those on in the dark of the morning.  

What is responsive design?

Responsive design is a technique for dynamically changing the layout of a web site for different browser widths giving priority to the most important content.  Ethan Marcotte coined the term.   He has a short book on the subject which is a must read.   
    
Responsive Design is not about creating a mobile specific site.  You have probably seen that done before; a website that has a desktop version and a mobile version.  There are so many devices being released every year that one cannot hope to have a site that will look good if you target a specific device or group of devices.  We don’t detect devices, we care about widths.  Furthermore, responsive design is less expensive to implement than creating a separate mobile site. 

Browser Compatibility

Responsive Design (specifically CSS Media Queries) work with these browsers:
  • Internet Explorer 9 and higher
  • Firefox 3.5 and higher
  • Safari 3 and higher
  • Chrome (any version)

Implementing Responsive Design Step by Step

1.  Create a base style sheet with the styles needed for desktop, laptops and older browsers.

<link rel="stylesheet" href="base.css">


2.  In the base style sheet, perform a CSS reset so that all modern browsers will render the same.

http://meyerweb.com/eric/tools/css/reset/

 

3.  In the base style sheet, tell images, embed, object, and video to resize to their maximum width.  


By specifying just the max-width, images and videos will keep their aspect ratio when resizing.  When the user shrinks their browser the images will automatically resize when their parent container becomes smaller.

/* Media Resizing */
img, embed, object, video
{
    max-width: 100%;
}




4.  In the base style sheet, make the minimum width for the body 320px.  


This is to prevent the user from resizing their browser smaller than the minimum width.  Set the font-size to 100%. We will need this later.

body {
     min-width: 320px;
     font-size: 100%;
}



5.  Add a meta tag

In your HTML page (or master page), add a meta tag to make the width of the browser port default to the device width with no zoom (scaling):

<meta name="viewport" content="width=device-width, initial-scale=1.0">



6.  Create a media query style sheet:

<link rel="stylesheet" href="mq.css">


7.  Create media query stubs

In the media query style sheet, create media queries based on common ports.  You will have ports in between these to tweak your site to look good in whatever size the user resizes the browser.   

/* Tablet Landscape */
@media screen and (max-width: 1024px) {
}

/* Tablet Portrait */
@media screen and (max-width: 768px) {
}

/* Big Smart Phones */
@media screen and (max-width: 640px) {
}

/* Mobile Landscape */
@media screen and (max-width: 480px) {
}

/* Mobile Portrait  */
@media screen and (max-width: 320px) {
}


8.  Decide what content is important.

Design for mobile first.  Ask, "How does this content or feature benefit our mobile users?"  http://www.lukew.com/ff/entry.asp?1117



9.  Define percentages for all your divs.

Below is the most important formula of your life (well concerning responsive design anyway).  Responsive design is about grid based percentages instead of the traditional fixed widths that you are used to.  You will need to convert fixed widths into percentages.

Result = Target / Context

Let’s say we have a navigation div and a main content div.

<div id="nav">
</div>

<div id="content">
</div>


Our wonderful designer, let's call him Doug, has said that the browser width is 1024 pixels and we have a 100 pixel navigation on the side and 924 pixels for the main content.  We are intentionally ignoring any padding or margin to keep things simple for this example. 

Navigation Percent = 100 / 1024

Main Content Percent = 924 / 1024

You would write something like the media query below, keeping all the decimal places you can from your calculator.  

/* Tablet Landscape */@media screen and (max-width: 1024px) {

     div#nav
     {
          width: 9.765625%;
     }

     div#content
     {
          width: 90.234375%;
     }
}


For nested divs, the context changes.  It would not be the width of the browser, but the width of the parent div.  So if we had a left inner div of 200 pixels and a right inner div of 262 pixels, the parent context would be 924 pixels because the content div is 924 pixels.  It might look like this:


<div id="nav">
</div>


<div id="content">
    <div id="left-content">
    </div>
   
    <div id="right-content">
    </div>
</div>


Here is the formula for the inner divs:

Inner Left Percent = 200 / 924

Inner Right Percent = 262 / 924


This is what we would have for the media query:

/* Tablet Landscape */@media screen and (max-width: 1024px) {

     div#nav
     {
          width: 9.765625%;
     }

     div#content
     {
          width: 90.234375%;
     }
   
     div#left-content {
        width: 21.64502164502165%;
     }
   
     div#right-content {
        width: 28.35497835497835%;
     }
}

10.    The strategy.  

My current strategy for remaining compatible with IE7 and IE8:
a.      Create a base style sheet that is percentage based (it needs to be outside of media queries).
b.      Create media queries from largest port to smallest port, overriding behavior as you get smaller.

11.   Change your fonts to use em-based.  

You are also used to creating fonts in points or pixels.  To make your site truly responsive, use the em-based fonts.  For example, to create a heading that is 3 times as large a normal font, it would be 3 em.  More information on em-based media queries:  www.cloudfour.com

h1
{
    font-size: 3em;
}


If the normal font of your page is 16px and you want a 24px heading do this to convert to ems.  You can leave the comments in there for reference.

h1 { font-size : 1.5em; /* 24px /16px */ }



Tips

  1. Don't use device-width or device-height for media queries.  We want the width of the browser port, not the width of the device.
  2. Use the Chrome Developer tools.  I have found that it is the easiest and fastest to use compared to Firebug and the IE Developer tools.  It is easy to change CSS percentages on the fly to see how it will look.  It updates in real time.  Right click and do an inspect element to see the tools.  Click on the width to change it.  After you are finished with the changes, go to the sources tab, select all and copy it into your development environment (Visual Studio, Eclipse, etc.).
  3. Use this piece of software to see if you converted the percentages correctly.  http://download.cnet.com/Pixel-Ruler/3000-12565_4-75312528.html
  4. Use this to make media queries work in IE5+ Firefox 1+ and Safari http://code.google.com/p/css3-mediaqueries-js/
  5. If you don’t want the older internet explorer to be responsive but you still want your website to render, you might need a separate style sheet for tweaks.  http://css-tricks.com/how-to-create-an-ie-only-stylesheet/

    <!--[if IE 7]>
        <link rel="stylesheet" type="text/css" href="/static/css/ie7.css">
    <![endif]-->
  6. IE10 may still have problems with some rendering.  Here is a workaround for that.  http://css-tricks.com/ie-10-specific-styles/

Example Responsive Design Sites


This is from the alist apart book:
http://responsivewebdesign.com/robot/

This is my first site doing responsive design:
www.kellermansoftware.com

This is my second site doing responsive design:
http://team.eas.com


These sites are mega cool
www.msj.edu
www.bostonglobe.com


References


Retrofitting
http://github.com/bencallahan/rwd-retrofitting

Media Queries
http://www.w3.org/TR/css3-mediaqueries

Media Types
http://www.w3.org/TR/CSS21/media.html#media-types

This is the best course on Responsive Design:
http://pluralsight.com/training/Courses/TableOfContents/responsive-web-design

Example Media Queries
www.mediaqueri.es