Wrox Programmer Forums
|
BOOK: Professional Visual Studio 2012
This is the forum to discuss the Wrox book Professional Visual Studio 2012 by Bruce Johnson; ISBN: 978-1-118-33770-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Visual Studio 2012 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 19th, 2013, 03:11 PM
Registered User
 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default TestContext in Chapter 11 Unit Testing

I had a problem (page 190) following along after creating the LoadTests database and adding the method.
Code:
public void CurrentStatusDataTest()
        {
            var target = new Subscription();
            var date = this.TestContext.DataRow["PaidUp"] as DateTime?;
            if (date!=null)
        	{
		         target.PaidUpTo=date;
	        }

            var val = Enum.Parse(typeof(Subscription.Status),
                this.TestContext.DataRow["Status"] as string);

            Assert.AreEqual(val, target.CurrentStatus, "Subscription.CurrentStatus was not set correctly.");
        }
There was no recognition of the TestContext. The book did not seem to mention where to put the TestContext object suggesting that it was automatically generated. After looking at the downloadable code and seeing the field and property declared in the SubscriptionTest class
Code:
/// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
I was wondering if the book was negligent in mentioning what TestContext is, how it works, and when it should be inserted. Also a more expansive detail on how it relates to the DataSource property (step 3, page 189) would be helpful.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7: Unit Testing with the Unit Testing Framework antwarpes BOOK: Professional Application Lifecycle Management with Visual Studio 2010 3 September 25th, 2011 08:47 AM
Chapter 7 Unit Testing with the Unit Test Framework - examples blaurence46 BOOK: Professional Application Lifecycle Management with Visual Studio 2010 1 September 24th, 2011 10:07 AM
Unit Testing jeffmorris BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 7 May 14th, 2007 06:51 AM
Unit Testing userrob BOOK: ASP.NET Website Programming Problem-Design-Solution 2 November 9th, 2005 10:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.