Friday 16 March 2012

Virtual Box Guest additions 4.1.10 and Windows 8 Consumer Preview (Black Screen)


The new version of Virtual Box guest additions 4.1.10 when installed in a Windows 8 Consumer preview Guest, after completing the installation it will (in some cases) display only a black screen.

To fix this, close your guest, and configure it with 3D acceleration. A 3d driver is installed by default is causing this issue.

Tuesday 2 August 2011

SpecFlow custom UnitTestProvider (Code generator) for Silverlight to access the Silverlight Test instance

When upgrading to Specflow 1.7 from the Async 2 branch, I have noticed that the new generator did not give you access to the Silverlight Test Instance. (This has been solved now https://github.com/techtalk/SpecFlow/pull/126, but it will be interesting to know how to solve this issue by creating your own unit test provider).

First you need to create a class which implements IUnitTestGeneratorProvider, in my case I have inherited directly from the MsTestSilverlightGeneratorProvider as follows. (Please note the code it is more or less the same as the original implementation).


public class SiverlightWithTestInstanceCustomGeneratorUnitTestProvider : MsTestSilverlightGeneratorProvider

{
public override void FinalizeTestClass(TechTalk.SpecFlow.Generator.TestClassGenerationContext generationContext)
{

base.FinalizeTestClass(generationContext);

var methods = from codeTypeMember in generationContext.Namespace.Types[0].Members.Cast()
where codeTypeMember.Name == "ScenarioSetup"
select (CodeMemberMethod)codeTypeMember;

var scenarioSetupMethod = methods.First();

var scenarioContext = new CodeTypeReferenceExpression("ScenarioContext");
var currentContext = new CodePropertyReferenceExpression(scenarioContext, "Current");

var scenarioContextExtensions = new CodeTypeReferenceExpression("ScenarioContextExtensions");

var setTestInstance = new CodeMethodInvokeExpression(scenarioContextExtensions, "SetTestInstance",
currentContext, new CodeThisReferenceExpression());

// Hmm. We have a little too much knowledge of where this should go, but it's after the call
// to testRunner.OnScenarioStart, and before FeatureBackground
scenarioSetupMethod.Statements.Insert(2, new CodeExpressionStatement(setTestInstance));
}
}




The class in this project, inserts the following line in the generated test:


   1:  ScenarioContextExtensions.SetTestInstance(ScenarioContext.Current, this);



public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)

{
TechTalk.SpecFlow.Async.AsyncTestRunner.RegisterAsyncTestExecutor(testRunner, new TechTalk.SpecFlow.Async.SilverlightAsyncTestExecutor(this));
testRunner.OnScenarioStart(scenarioInfo);
ScenarioContextExtensions.SetTestInstance(ScenarioContext.Current, this);
this.FeatureBackground();
}




This is necessary if you want to get access of the SiverlightTest like:

var silverlightTest = ScenarioContext.Current.GetTestInstance<SilverlightTest>();

to do things like:

 silverlightTest.TestPanel.Children.Add(myView);


I have not figured out if it is possible to configure specflow to read this from a different assembly, so for the time being you can
1. Get the version of Specflow you are currently working on

2. Add the class to the project TechTalk.SpecFlow.Generator. In the folder UnitTestProvider.


3. Compile and put the new dll where SpecFlow is configured, in case of doubt see the example of configuration bellow:


<generator path="..\..\packages\SpecFlow.1.7.0\tools" generateasynctests="true"></generator>


To run your custom generator add this line to your app.config, please note that I have given a random name to my unitTestProvider, (not matching the generic ones)


<unittestprovider name="customSL" generatorprovider="TechTalk.SpecFlow.Generator.UnitTestProvider.SiverlightWithTestInstanceCustomGeneratorUnitTestProvider" />




Thursday 22 April 2010

Silverlight 4 Resources - Free training course

Silverlight 4 Training

Microsoft is offering a free Silverlight 4 training course, great place to get started.

The Silverlight 4 Training Course includes a whitepaper explaining all of the new Silverlight 4 features, several hands-on-labs that explain the features, and a 8 unit course for building business applications with Silverlight 4. The business applications course includes 8 modules with extensive hands on labs as well as 25 accompanying videos that walk you through key aspects of building a business application with Silverlight. Key aspects in this course are working with numerous sandboxed and elevated out of browser features, the new RichTextBox control, implicit styling, webcam, drag and drop, multi touch, validation, authentication, MEF, WCF RIA Services, right mouse click, and much more!

You can download the course here: http://www.microsoft.com/downloads/details.aspx?FamilyID=24CEA29E-042E-41C9-AA16-684A0CA5F5DB&displaylang=en

You can also view the course at Channel 9 http://channel9.msdn.com/learn/courses/Silverlight4/

Course content:

What's New in Silverlight 4

Make this your first stop with Silverlight 4 and read or download the 60+ page whitepaper! Walk through the new features in Silverlight 4, find learning materials and additional resources. This covers all of the new business centric features, features for rich media experiences, Expression Blend and Visual Studio tooling enhancements, and new Out of Browser features!



Silverlight 4 New Features

Check out these 5 hands on labs that demonstrate some of the newest features in Silverlight. Explore multi touch, drag and drop, numerous out of browser features, learn to interact with the webcam, create a rich text notepad using the RichTextBox control, printing your content, and more!



Silverlight 4 Business Apps: Module 1 - Introduction Silverlight 4 Business Apps

John Papa and Ian Griffiths discuss the key areas that the Building Business Applications with Silverlight 4 course focuses on. This module is the overview of the course which covers many key scenarios that are faced when building business applications and how Silverlight can help address them.



Silverlight 4 Business Apps: Module 2 - Event Manager using WCF RIA Services

This is module 2 of the Building Business Applications with Silverlight 4 course. This module sets the stage with the course's Event Manager application. It discusses using WCF services vs WCF RIA Services. Then it walks you through integrating WCF RIA Services into the solution to support reading, editing and inserting entities. This unit also covers the key aspects of data binding and page navigation.



Silverlight 4 Business Apps: Module 3 - User Registration with Authentication, Validation, Rich Text, Styling, and Commands

User Registration with Authentication, Validation, Rich Text, Styling, and Commands This is module 3 of the Building Business Applications with Silverlight 4 course. This module covers authentication, using the DataForm, setting up validation for the model, the RichTextBox control, implicit styling, commanding, and the fundamentals of MVVM.



Silverlight 4 Business Apps: Module 4 - User Profile with Drop Target, Webcam, Clipboard

This is module 4 of the Building Business Applications with Silverlight 4 course. This module covers dropping a file onto a Silverlight application, programmatic clipboard access, and accessing the webcam.



Silverlight 4 Business Apps: Module 5 - Schedule Planner with Grouping and Right Click

This is module 5 of the Building Business Applications with Silverlight 4 course. This module covers grouping in a DataGrid and an ItemsControl. It also covers the new Fluid UI visual states, right mouse click, and word based text trimming.



Silverlight 4 Business Apps: Module 6 - Printing the Schedule

This is module 6 of the Building Business Applications with Silverlight 4 course. This module covers the fundamentals of printing in Silverlight. It also offers some techniques for printing multiple pages.



Silverlight 4 Business Apps: Module 7 - Event Dashboard Running Out of Browser

This module covers several out of browser features including creating toasts, window placement, elevated trust, and native integration.


Silverlight 4 Business Apps: Module 8 - Advanced Out of Browser and MEF

This module covers more out of browser features including creating custom chrome, the window closing event, silent installs, and XAP signing. It also covers MEF and how it enables composability, supports a plug in model, and can dynamically load XAP files.