DCSIMG
February 2010 - Posts - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

February 2010 - Posts

Introduction To CodedUI and Microsoft Test Manager – Developer Academy 4

automation

Introduction To CodedUI and Microsoft Test Manager – Developer Academy 4

Developer Academy 4 - Intruduction To CodedUI Testing And Microsoft Test Manager is around the corner, I’m going to talk about one of the most amazing features in Visual Studio 2010 – Testing, or should I say – Super Advanced and Easy Automation Ability.

In my session I’ll talk about CodedUI Testing, Data Adapters (off course how to create a custom adapter) and a lot more cool stuff, and short demo on CodedUI success story from Intel.

So if you want to hear about the future of testing visit Developer Academy 4 Site

Developer Academy 4 Sessions | Speakers | Registration

TFS API Part 22 – Create Link Between Work Item (Parent, Child etc…)

TFS API Part 22 – Create Link Between Work Item (Parent, Child etc…)

I got couple of question regarding Custom Link Types in TFS 2010, as you know one of the most important features in 2010 is new Link and Hierarchy capability.

In this post I’ll show and give a demo application on how to create custom link type through TFS API.

image

Download Demo Project

Step 1: Create Project and Add Reference

Create an WPF/WinForm application and add the following references:

     Microsoft.TeamFoundation.WorkItemTracking.Client.dll
(C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll)
     Microsoft.TeamFoundation.Client.dll
(C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll)

Step 2: Connect to Team Foundation Server

private WorkItemStore store;

private TfsTeamProjectCollection tfs; – As you can see TeamFoundationServer is obsolete –

TFS API Part 20: Bye TeamFoundationServer and Welcome TfsTeamProjectCollection 

TeamProjectPicker pp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);

pp.ShowDialog();

 

if (pp.SelectedTeamProjectCollection != null)

{

    this.tfs = pp.SelectedTeamProjectCollection;

    pp.SelectedTeamProjectCollection.EnsureAuthenticated();

    this.store = (WorkItemStore)pp.SelectedTeamProjectCollection.GetService(typeof(WorkItemStore));               

    GetLinkTypes();

    ActiveForm();

}

 

Step 3: Get Link Types From WorkItemStore
image

Using WorkItemStore object you can take all Link Types from TFS, I created a new object to contain all the information in LinkTypeItem.

void GetLinkTypes()

{

    foreach (WorkItemLinkType type in store.WorkItemLinkTypes)

    {

        combo_types.Items.Add(new LinkTypeItem(type));

    }

}

 

public LinkTypeItem(WorkItemLinkType type)

{

    this.CanDelete = type.CanDelete;

    this.CanEdit = type.CanEdit;

    this.ForwardEnd = type.ForwardEnd;

    this.IsActive = type.IsActive;

    this.IsDirectional = type.IsDirectional;

    this.IsNonCircular = type.IsNonCircular;

    this.IsOneToMany = type.IsOneToMany;

    this.LinkTopology = type.LinkTopology;

    this.ReferenceName = type.ReferenceName;

    this.ReverseEnd = type.ReverseEnd;

}

 

Step 4: Create Link Between Work Items

image

try

{

    LinkTypeItem type = combo_types.SelectedItem as LinkTypeItem;

    int from_wit = Convert.ToInt32(txt_wit_from.Text);

    int to_wit = Convert.ToInt32(txt_wit_to.Text);

 

    WorkItem from = store.GetWorkItem(from_wit);

 

    //Define what type of link to add.

    //Child, Parent etc...

    WorkItemLinkTypeEnd linkTypeEnd = store.WorkItemLinkTypes.LinkTypeEnds[type.ReverseEnd.Name];

    //Add the link as related link.

    from.Links.Add(new RelatedLink(linkTypeEnd, to_wit));

    from.Save();

 

    MessageBox.Show(string.Format("Work Item {0}, is {1} of Work Item {2}",

        from_wit, type.ReverseEnd.Name, to_wit),

        "Relation Saved",MessageBoxButton.OK,MessageBoxImage.Information);

}

catch (Exception ex)

{

    MessageBox.Show(ex.Message,"Cannot Save Work Item Relation",MessageBoxButton.OK,

        MessageBoxImage.Error);

}

 

Using Demo Application:

Open demo application select the desire link type and write two work item numbers: From work item and To work item ids.

After you click the “Create Link” button you should see message box with the result.

image

Also you should check in Team System:

image

 

In the pictures above I’ve used Hierarchy link type between work item 8 and 12, when trying to create circular relationships I got the following error, read more about Link Types: TFS 2010 Work Item Link Types

 

image

Download Demo Project

Enjoy

TFS 2010 Work Item Link Types

TFS 2010 Work Item Link Types

Couple of post before I talked about the new Links available in Team System 2010 - VSTS 2010 – Work Item Relations (Visual).

Here is more details on Link Types in Team System 2010.

Network: You can use network links to create basic relationships between work items that are non-restrictive. The link is the same at both end points. Circular relationships are allowed.

Example usage: Use a network link, such as Related, to record a relationship between two features that might share dependencies.

Topology of Network Links

Directed Network: You can use directed network links to create relationships between work items that indicate directionality. The link name is different at the end points. Circular relationships are allowed.

Example usage: Use a directed network link to record a relationship between two features that might share dependencies and which you want to distinguish from each other in some way.

Topology of Directed Network Links

Dependency: You can use dependency links to create relationships between work items that have directionality and to restrict circular relationships. The link name is different at the end points.

In the illustration, you cannot create a dependent link to a work item that contains dependent link relationships to the same work items.

Example usage: Use a dependency link to record the features that must be completed to deliver a user requirement.

Topology of Dependency Links

Tree: You can use tree links to create multi-level hierarchical relationships among work items. Tree links support multi-level hierarchical views, have directionality, and restrict circular relationships. The link name is different at the end points. Tree links are the only type of link that is supported by the Tree of Work Items query.

In the illustration, you cannot assign two parents to a child.

Example usage: Use a tree link to record tasks and subtasks from your team that must be completed to deliver a feature.

Topology of Tree Links

VS 2010 RC Intellisense Crash Issue – Patch

VS 2010 RC Intellisense Crash Issue – Patch

Over the last week I had one big problem with Visual Studio 2010 RC, while writing code in visual studio and used the Intellisense VS crashed.

Before I reinstall Visual Studio 2010 RC I found out that Patch available for this problem, You can download and run it here.

This Fix is not just for crashes with the VS 2010 RC, also if you have a tablet, multi-touch, screen-reader or external devices attached (including Wacom tablets, phones/ipods, and others that connect via USB).

image

Error Log:

Fault bucket , type 0
Event Name: CLR20r3
Response: Not available
Cab Id: 0

Problem signature:
P1: devenv.exe
P2: 10.0.30128.1
P3: 4b611627
P4: Microsoft.VisualStudio.Platform.VSEditor
P5: 10.0.0.0
P6: 4b60f36e
P7: 9d7
P8: 29
P9: System.InvalidOperationException
P10:

Attached files:
C:\Users\Shai Raiten\AppData\Local\debuggee.mdmp
C:\Users\Shai Raiten\AppData\Local\Microsoft\VSCommon\10.0\SQM\sqmdata.cvr

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportArchive\Critical_devenv.exe_79b54d639b45914372ccfe1bccb8a97c76299d_3a184f19

Analysis symbol:
Rechecking for solution: 0
Report Id: 2351b8e1-2151-11df-853e-00225f2273f6
Report Status: 1

TFS 2010 RC Power Tools are Available!

TFS 2010 RC Power Tools are Available!

Brain Harry just post that Power Tools for TFS RC are available for download from here:

Power Tools

MSSCCI Provider

Please make sure you uninstall any previous VS 2010 versions of the Power Tools before installing these.  They should work side by side with the VS 2008 Power Tools though.

Full Post

TFS API Part 21: Delete Work Item using WorkItemStore (Demo Application)

TFS API Part 21: Delete Work Item using WorkItemStore

Over the last weeks I heard couple of times a fast way to delete work items from Visual Studio 2010, so in this post I’ll show how to build a simple Delete Work Item application using WorkItemStore.

*** Deleting Work Item Action Is Not Recoverable ***

image 

Download Demo Project

Create WinForm or WPF application project and add the following reference:

First add reference for
     Microsoft.TeamFoundation.WorkItemTracking.Client.dll
(C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.WorkItemTracking.Client.dll)
     Microsoft.TeamFoundation.Client.dll
(C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.TeamFoundation.Client.dll)

Step 1: Connect to Server

TeamProjectPicker pp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);

    pp.ShowDialog();

 

    if (pp.SelectedTeamProjectCollection != null)

    {

        pp.SelectedTeamProjectCollection.EnsureAuthenticated();

        store = (WorkItemStore)pp.SelectedTeamProjectCollection.GetService(typeof(WorkItemStore));

    }

Step 2: Delete Work Item

As you can see 2010 API supports work item deletion, calling WorkItemStore object will allow you using DestroyWorkItems method.

IEnumerable<WorkItemOperationError> DeleteWorkItem(int[] ids)

{

    try

    {

        return store.DestroyWorkItems(ids);

    }

    catch (Exception ex)

    {

        MessageBox.Show(ex.Message);

        return null;

    }

}

Step 3: Check For Errors

DestroyWorkItems will return a IEnumerable<WorkItemOperationError>, when everything is OK the collection will be empty.

void DeleteStatus(IEnumerable<WorkItemOperationError> enumerable)

{

    List<WorkItemOperationError> list = new List<WorkItemOperationError>(enumerable);

    if (list.Count > 0)

    {

        StringBuilder builder = new StringBuilder();

        for (int j = 0; j < list.Count; j++)

        {

            builder.AppendLine(string.Format("Work Item Id:{0}, {1}", list[j].Id, list[j].Exception.Message));

        }

        MessageBox.Show(builder.ToString(),"Error Deleting Work Item",MessageBoxButton.OK,MessageBoxImage.Error);

    }

    else

    {

        MessageBox.Show("Done");

        txt_id.Text = string.Empty;

    }

}

Full Code:

private void btn_server_Click(object sender, RoutedEventArgs e)

{

    btn_delete.IsEnabled = false;

    TeamProjectPicker pp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false);

    pp.ShowDialog();

 

    if (pp.SelectedTeamProjectCollection != null)

    {

        pp.SelectedTeamProjectCollection.EnsureAuthenticated();

        store = (WorkItemStore)pp.SelectedTeamProjectCollection.GetService(typeof(WorkItemStore));

        btn_delete.IsEnabled = true;

    }

}

 

IEnumerable<WorkItemOperationError> DeleteWorkItem(int[] ids)

{

    try

    {

        return store.DestroyWorkItems(ids);

    }

    catch (Exception ex)

    {

        MessageBox.Show(ex.Message);

        return null;

    }

}

 

void DeleteStatus(IEnumerable<WorkItemOperationError> enumerable)

{

    List<WorkItemOperationError> list = new List<WorkItemOperationError>(enumerable);

    if (list.Count > 0)

    {

        StringBuilder builder = new StringBuilder();

        for (int j = 0; j < list.Count; j++)

        {

            builder.AppendLine(string.Format("Work Item Id:{0}, {1}", list[j].Id, list[j].Exception.Message));

        }

        MessageBox.Show(builder.ToString(), "Error Deleting Work Item", MessageBoxButton.OK, MessageBoxImage.Error);

    }

    else

    {

        MessageBox.Show("Done");

        txt_id.Text = string.Empty;

    }

}

 

private void btn_delete_Click(object sender, RoutedEventArgs e)

{

    if (!string.IsNullOrEmpty(txt_id.Text) && IsInteger(txt_id.Text))

    {

        IEnumerable<WorkItemOperationError> enumerable;

        int[] ids = new int[] { Convert.ToInt32(txt_id.Text) };

        enumerable = DeleteWorkItem(ids);

        DeleteStatus(enumerable);

    }

}

 

public static bool IsInteger(string theValue)

{

    try

    {

        Convert.ToInt32(theValue);

        return true;

    }

    catch

    {

        return false;

    }

}

image 

Download Demo Project

HowTo: Upgrade CodedUI Test From Beta 2 To RC

HowTo: Upgrade CodedUI Test From Beta 2 To RC

If you have created CodedUI Test in Visual Studio Team System 2010 Beta 2 and you upgrade Visual Studio to RC than you have a problem.

This is because Microsoft changed specialized classes like HtmEdit, WinWindow, WpfButton and more and have been added them to the product, instead of generate UserControls file.
Take Notice UserControls will be not add to the project any more!!! Awesome!

You will see that Beta 2 CodedUI Test are no longer compiling under RC version, Do worry you can fix this in a sec.

image

What you need to do is run UITestUpgrade.exe located in
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE and specify the CodedUI Test folder.

(For 32bit OS - C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE)

Example: UITestUpgrade.exe “C:\Tests\CodedUILib”

image

And now every thing should work just fine.

Enjoy.

TFS API Part 20: Bye TeamFoundationServer and Welcome TfsTeamProjectCollection

TFS API Part 20: Bye TeamFoundationServer and Welcome TfsTeamProjectCollection

In my last post I talked about Upgrade Team System Beta 2 To RC – Smooth and the amazing performance improvement in Visual Studio.

Trying to compile a old TFS utility with Visual Studio RC, I found out the TeamFoundationServer class is obsolete, The replacement is TfsTeamProjectCollection or TfsConfigurationServer classes to talk to a 2010 Team Foundation Server.
In order to talk to a 2005 or 2008 Team Foundation Server use the TfsTeamProjectCollection class.

public TfsTeamProjectCollection(RegisteredProjectCollection projectCollection);

public TfsTeamProjectCollection(Uri uri);

public TfsTeamProjectCollection(RegisteredProjectCollection projectCollection, IdentityDescriptor identityToImpersonate);

public TfsTeamProjectCollection(Uri uri, ICredentials credentials);

public TfsTeamProjectCollection(Uri uri, ICredentialsProvider credentialsProvider);

public TfsTeamProjectCollection(Uri uri, IdentityDescriptor identityToImpersonate);

public TfsTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentials credentials, ICredentialsProvider credentialsProvider);

public TfsTeamProjectCollection(Uri uri, ICredentials credentials, ICredentialsProvider credentialsProvider);

public TfsTeamProjectCollection(RegisteredProjectCollection projectCollection, ICredentials credentials, ICredentialsProvider credentialsProvider, IdentityDescriptor identityToImpersonate);

public TfsTeamProjectCollection(Uri uri, ICredentials credentials, ICredentialsProvider credentialsProvider, IdentityDescriptor identityToImpersonate);

Here is couple of older post on how to connect TFS using API

TFS API Part 1: Domain Picker

TFS API Part 2: Domain Picker Using Registered Servers (Cache)

TFS API Part 13: More About Connecting TFS (Custom Credentials, Prompt)
 
Enjoy

Test Manager 2010 (RC) – What’s New

image

Test Manager 2010 (RC) – What’s New

In my last post I’ve talked about how to upgrade you TFS - Upgrade Team System Beta 2 To RC – Smooth, I didn’t post anything about how to upgrade Visual Studio Beta2 to RC, because all you need to do is uninstall Beta 2 and Install the RC.(If you used Beta 2 Modeling projects take a look at this post - Visual Studio 2010 RC – Unable To Load Modeling Project From Beta 2).

So what’s new in RC:

1. Speed Speed Speed, Microsoft did a great job with Test Manager performance issues.

2. Previous versions of MTLM didn’t had one feature that is very important to manage a full QA process – Create Various Types Of Work Items,  until the RC MTLM users can only open Bugs and Test cases.
So now you can create all types of work items from Test Manager.

image

3. New button in Test Run will allow you to jump the next iteration.

image

Hierarchy View – Yes, it’s not a joke, in Beta 2 only Visual Studio users were able to view work item hierarchy, so now you can see the same queries and views as Visual Studio, also you can create your own queries very easily from Test Manager.

image


Data and Diagnostics – More details on what you want to collect, and Profiler was removed from that list.

image

Verify Bug  - Now you can change the default queries not only the Custom.

image

Visual Studio 2010 RC – Unable To Load Modeling Project From Beta 2

Visual Studio 2010 RC – Unable To Load Modeling Project From Beta 2

After upgrading to Visual Studio RC I was unable to open Modeling project that were created in Visual Studio Beta 2.

There is a very quick workaround to solve this issue by modifying the modelproj file.

There are only three actions need to be done:

1. Backup your projects.

2. Open modelproj file and change the version to 1.0.0.0 (0.3.0.0) and attribute name from TeamArchitect to ArchitectureTools

3. Define the new path where Modeling project targets are placed.

4. Platform need to be – AnyCPU.

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

    <SchemaVersion>2.0</SchemaVersion>

    <ProjectGuid>{00000000-0000-0000-0000-000000000000}</ProjectGuid>

    <TeamArchitect>0.3.0.0</TeamArchitect>    --->>> Change To --->>> <ArchitectureTools>1.0.0.0</ArchitectureTools>

    <Name>ModelingProject1</Name>

    <RootNamespace>ModelingProject1</RootNamespace>

  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

    <OutputPath>bin\Debug\</OutputPath>

  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

    <OutputPath>bin\Release\</OutputPath>

  </PropertyGroup>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\TeamArchitect\Microsoft.VisualStudio.TeamArchitect.ModelingProject.targets" />

--->>> Change To --->>>

  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\ArchitectureTools\Microsoft.VisualStudio.TeamArchitect.ModelingProject.targets" />

  <ItemGroup>

    <Folder Include="ModelDefinition\" />

    <Content Include="ModelDefinition\ModelingProject1.uml">

      <SubType>Content</SubType>

    </Content>

  </ItemGroup>

</Project>

Now you should be able to load your Modeling project, but not yet all the items related (UML,VCL, etc…)

To complete the “Upgrade” run a quick search and find and replace dslVersion="0.3.0.0" with dslVersion="1.0.0.0"

(Some items had code behind so make sure you search all the items.)

Save and every thing should work.

Hope this helps.

 

Upgrade Team System Beta 2 To RC – Smooth

Upgrade Team System Beta 2 To RC - Smooth

As you know Microsoft Released Visual Studio 2010 RC for everyone, RC version is still under GoLive!

The most important improvement in Team System RC, is the performance! and yes, Microsoft Did an Amazing Job!!!

If you already installed Visual Studio Team System 2010 Beta 2, and you want to upgrade here is a short guide:

1.Backup you machine \ Databases.

2.Uninstall Visual Studio Team System 2010 Beta 2.

3.Uninstall Team Foundation Server 2010 Beta 2.

4. Install Team Foundation Server 2010 RC.

5. In the configuration Wizard select - Upgrade

image

From TFS data tier select the Configuration Database.

image

Make sure all test passed and finish the configuration.

 image

image

And you’re done!!! Fast and Smooth!

image

Microsoft MVP’s,MRD’s, MRS’s and UG Managers Summit - Israel

Microsoft MVP’s,MRD’s, MRS’s and UG Managers Summit - Israel

Microsoft Israel arranged a “Movie Meeting” (we saw Avatar – My second time – still great movie) for all Microsoft Experts in Israel.
The event were take place in Rav-Chen Ayalon Ramat-Gan, good food, drinks, gadgets and most important good People.

It’s very nice to take a break from work and meet all those great people in one place without work involved :-D

Here is some pictures from the event:

IMG_3921 IMG_3922 IMG_3923 IMG_3924 IMG_3925 IMG_3926 IMG_3927 IMG_3928 IMG_3929 IMG_3930 IMG_3931 IMG_3932 IMG_3933 IMG_3934 IMG_3935  IMG_3937 IMG_3938 IMG_3939 IMG_3940 IMG_3941 IMG_3942  IMG_3944 IMG_3945  IMG_3948  IMG_3950 IMG_3951 IMG_3953 IMG_3954 IMG_3955 IMG_3956 IMG_3957 IMG_3958 IMG_3914 IMG_3915 IMG_3916 IMG_3917 IMG_3918 IMG_3919 IMG_3920

Posted: Feb 08 2010, 11:34 PM by shair | with 3 comment(s)
תגים:, , ,