TechNight - Windows Communication Foundation
March 19, 2006
This is the material about Windows Communication Foundation (code-name Indigo) which was exposed on Microsoft WinFx TechNight (2006-03-17), for Windows Presentation Foundation & Windows Workflow Foundation go to Angel "Java" Lopéz personal site. Thanks to everybody who came and I hope have you enjoyed the experience. Feedback will be welcome and questions too.
Important: To run the samples you will need to install the following components:
- Windows XP Service Pack 2 or Windows Vista February CTP (build 5308) on an x86 system
- February 2005 WinFX Community Technology Preview
- February 2006 WinFX SDK
- Microsoft Visual Studio 2005 or Microsoft Visual C# Express 2005
- Visual Studio 2005 Extensions for WinFX
Note: If you have suggestions or something about WCF that you want to know / understand ask me and I’ll prepare a post to help you.
Este es el material de Windows Communication Foundation (code-ame Indigo) que fue expuesto en el TechNight de Microsoft WinFx (2006-03-17), para conseguir el materiañ de Windows Presentation Foundation & Windows Workflow Foundation visiten el sitio de Angel "Java" Lopéz. Gracias a todos los que vinieron y espero que hayan disfrutado la experiencia. Feedback y preguntas seran bienvenidas.
Importante: Para correr los ejemplos necesitaran instalar los siguientes componentes:
- Windows XP Service Pack 2 or Windows Vista February CTP (build 5308) on an x86 system
- February 2005 WinFX Community Technology Preview
- February 2006 WinFX SDK
- Microsoft Visual Studio 2005 or Microsoft Visual C# Express 2005
- Visual Studio 2005 Extensions for WinFX
Nota: Si tienes sugerencias o algo que quieran saber o entender sobre WCF , preguntenme y prepararé un post para ayudarlos.
TechNight - Windows Foundations
March 16, 2006
Tomorrow night I’ll be presenting Windows Foundations with Angel “Java” Lopez, MVP J#.
In this session we will discuss the future of Windows platform. We’ll talk about Windows Foundations, the declarative programming language (XAML) and the importance of designing SOA applications using System.ServiceModel (Windows Communication Foundation namespace). Here is the agenda for this conference:
Windows Presentation Foundation
- What is WPF?
- XAML, the new declarative programming language.
- WPF in Windows Vista.
- Using WinForms with WPF.
- WPF and Microsoft Expression Products.
Windows Workflow Foundation
- What is WF?
- WF key concepts and components.
- Human Workflows vs. System Workflows.
- Types of workflow authoring.
- Writing custom activities.
- XAML & XOML
Windows Communication Foundation
- What is WCF?
- WCF Application Model and Application Design
- The Windows Communication Foundation ABC
- Contracts, Bindings and Behaviors
- Deep dive into Bindings
- Configuring service.
- Interoperability, a simple example
- Consuming WCF from VS.NET 2003
- Consuming ASMX from WCF
- WCF Hosting Model
And then we’ll show a complete Cross-Technology sample.
TDD using Microsoft Visual Studio Team Edition
March 15, 2006
NOTE: Before you continue you need to install MS Visual Studio Team Edition for Testers.
I’ll explain how to use TDD with MS Visual Studio using a real life example. As stated in my previous post, there are a couple of steps that you can check to make sure that you are aligned with TDD.
1st – Requirement
Consider a bag that implements the following methods IsEmpty, Pop, Push. These are the behavior considerations about the bag.
- If the bag is empty; the IsEmpty method must return true. If not it must return true.
- If you pop an item into the bag, the IsEmpty method must return false.
- If you push an item from the bag , where the item count equals to one it should return true.
2nd – Test List
- Create a Bag and check that isEmpty is true.
- Push a single object into the Bag and check that isEmpty is false.
- Push a single object and then pop it from the bag and check that isEmpty is true
3rd – Choose you first test
For this example we’ll use “Create a Bag and check that isEmpty is true.”.
4th – Follow the implementation list that I
mentioned in the other post
Step 0 – Create you solution
- Open Microsoft Visual
- Go to File -> New -> Project
- Select Other Project Types -> Visual Studio Solutions -> Blank Solution
- Type TDD Example in the Name textbox.
- Go to File -> Add -> New Project
- Select Visual C# -> Test Projects -> Test Projects
- Type Bag.Test in the Name textbox.
Step 1 – Write Test Code
Write the following code as your test code
[TestMethod]
public void CheckBagIsEmpty()
{
Bag myBag = new Bag();
Assert.AreEqual(true, myBag.IsEmpty);
}
Step 2 – Compile the test code
Nothing to say, just press Shift + Ctrl + B.
Step 3 – Implement enough to compile
- Add a class to your test project called bag.
- And write the following code
public class Bag
{
public bool IsEmpty
{
get { return false; }
}
}
Step 4 – Run the test and see it fail
- Press Shift + Alt + X.
- See it fails with the following error message “Assert.AreEqual failed. Expected:<True>, Actual:<False>.”
Step 5 – Implement just enough to make test pass
Replace isEmpty method with the following code
public bool IsEmpty
{
get { return true; }
}
Step 6 – Run the test and see it pass.
- Press Shift + Alt + X.
- See it pass.
- You’ll get 1/1 passed as result
Step 7 – Refactor for clarity and to eliminate duplications
You bag class should look like
public class Bag
{
private bool _isEmpty;
public bool IsEmpty
{
get { return _isEmpty; }
set { _isEmpty = value; }
}
public Bag()
{
this._isEmpty = true;
}
}
Re run your test and see it pass, with the refactored bag class.
Summary
Now you know how to write a simple test on Microsoft Visual Studio Team Edition For Testers, you’ve seen the development lifecycle of a requirement with VS for Testers.
Test Driven Development
March 15, 2006
Today I was asked how familiar I was with TDD and what was my opinion about it. Since I never posted about this I will do so! Later I will post about things like Scrum and TDD using Microsoft Visual Studio Team Edition
Test Driven Development
So What is Test Driven Development? To answer this question I would like to quote Kent Beck. In his book TDD : By example (Addison Wesley Professional, 2003)
“Test Driven Development is defined under the following rules:
- Never write a single line of code unless you have a fallen automation test.
- Eliminate duplication”
The first rule is really clear, it’s means that you must have an Automation Test written before writing any code line. That is because TDD maps a requirement as a test. I think this really straight forward, if you don’t have a test (requirement) why bother? there’s no need to implement write any code. This rule empowers developers to be pragmatic and focused on the solution scope.
The second one states that no code should be duplicated, because code duplication leads to bad software design. This rule is derived from Extreme Programming where it’s called “Once and Only Once”.
I would like to make clear that it is wrong to think that TDD is about unit testing alone. There’s another kind of test called a Customer Test. Some authors call them functional tests or acceptance tests. These kinds of tests are used to understand and establish functional requirements and customer experience. They try to express what the customer needs and wants. This kind of test is usually implemented with what is called navigation story boards.
KIS (Keep It Simple)
TDD suggests writing the minimal amount of code needed to successfully run a test and nothing else. That means you should only satisfy current requirements. Although this may seem obvious to a lot of people, this is usually not so. Most developers often write code to cope with requirements that they think might pop up in the future and by doing so they add code that is not needed at the moment. TDD is strongly against this kind of behavior; remember TDD is to keeping the project on scope.
Many people ask me, how to recognize if the are writing good TDD code? One alternative may be looking at the following checklist:
- Is the code appropriate for the intended audience?
- Is the code passing all the tests.
- Is the code communicating everything it needs to (Remember no more & no less)
- Is the code written in the simplest way (I strongly recommend you to read Steve’s McConnell Code Complete 2nd Edtion).
Refactoring is the key
I suggest you to follow these steps when writing tests, as guide for good TDD practices:
- Write the test code
- Compile the test code (If you are following the list, it will failed because you haven’t implemented the actual code)
- Only write just enough code to compile.
- Run the test and see it fail.
- Implement just enough to pass the test
- Re run the tests and see them pass.
- Refactor for clarity and to eliminate duplication (Remember the 2nd rule!).
- Repeat this until your code looks as simple as it can.
When you are finished implementing the code you’ll be able to test future changes on the program. There should be minimal usage of the debugger because the steps are so small that you should know which change was the one that caused the tests to fail.
“Working in small, verifiable steps increase your speed in moving forward because you will be moving with more confidence; the confidence is the result of feedback that running the tests provides your” (Extract from TDD in Microsoft.net, Newkirk & Voronstov, MS Press, 2004).
Summary
TDD is about keeping the code as small as you can (by avoiding the things that you don’t need right now and avoiding duplication with refactoring).
Windows SDK FEB CTP Issue
March 6, 2006
There´s a known issue in the Feb CTP of Windows SDK. If you want to use CertMngr or install the examples in Windows XP Sp2 or Windows 2003 you’ll get an error the reason is:
Some tools are built to run only on Windows Vista
The following tools are built to run only on the Windows Vista operating system. If you attempt to run them on Windows XP SP2 or Windows Server 2003, you will see an error message stating that the executable is not a valid Win32 application.
- CertMgr.exe
- Checkv4.exe
- MakeCat.exe
- MakeCert.exe
- MakeCtl.exe
- SetReg.exe
- SpOrder.exe
- Where.exe
Workaround
Use these tools on the Windows Vista operating system.
Another workaround is to use the Jan version of these tools.