In part 6 I continue doing some Test Driven to actually make our unit test go to the green state. I also show some quick ADO.NET Entity Framework use and finally how to check-in your code to Team Foundation Server while associating that check-in with the developer task.
hi my name is hula castle and in this
video we will continue the work that we
were doing in the past video trying to
make some test driven development in the
studio 2010 ok and a also learning how
to check in your source code into the
team foundation server associating these
without work item so if you remember we
were we just created our first giving
test in the trust even development way
where we're just instigating a new
instance well sorry a new instance of
the money your class and getting a
little books and asserting it is not
known as you already know this is just
not passing right click there this is
not bad so how to make this actually
pass let's close this and quick notice
we are going to use a database for this
exercise if i open my sequel server
management studio let me show you we are
using the pups database are very popular
and old database k back from the sequel
server 2000 days and it's a simple
database that has some information on on
books okay books book sales and that
stuff so we will be using the database
you will easily find that in the in the
web so and what we want to do now is to
go to the bookstore that business
applique project click add new item and
let's go to the data category and select
a do net entity data model be here let's
add a new model and let's let's use some
useful name let's call these pups
entities as we will be using some
entities from the pups database solidly
hit add okay so we will select generate
from the database ok this is this is our
database sinkhole express that part of
the VoIP you don't have this this option
right here just click new connection and
go ahead and create your connection so
let's call these pups entities this is
the name in the application corporation
file well the connection string will be
created in here a vicious to this
retrieving all the objects that it's
finding in this database for now we will
just select the tables and let's name
this pups model and let's click finish
so well this wizard is going to do right
now is adding all the references to the
idea that net entity data model and it
is creating or our diagram or entities
diagram will Elise just as you can see
right now it is placing all the tables
that we selected from the wizard and
it's also adding all the references from
these tables so it is a very useful
model for our job so we will be very
interested in this title in this title
table so let's go here and let's go to
the book manager class which right now
has a get boot list method which has
something that we don't really want to
have right there so what we want to do
now is to write the code for this so
let's just delete this and we will just
use some link to entities to retreat the
information that we want and we want to
retrieve information remember from this
title table let me do this ok so we have
some idea what we're doing here ok we
want to retrieve information from title
table and on the fly we will just create
instances of the book of the book class
that we already defined it in the or in
our test how to do that so first thing
to do we need a context to do this so we
will just call pops entities let me go
back to the other intelligence
configuration control out space bar this
makes it easier to select a obvious that
we already have so pops entities let's
call it context equals new pops entities
so let's say we want to borrow books
variable and let's say select from be4
book in context that titles okay which
is a table we want to get in for from
select what are we going to select a new
book okay so this book it will be made
off of the following a privates let's
say an ID we also always record an ID
which is B dot title ID okay as you can
see we don't have an ID attribute so
let's just create it in your
appropriately stop for ID in books or
business book okay it now exists now
let's go for title equals B dot title
won okay we will create all this stuff
in the end type equals V dot sorry be
that type okay price equals B that price
and final one will be description equals
B that pop date okay let's create all
these and ops what am I doing here skull
my coma coma so let's create a title
properly okay let's create the
description property okay
okay so a little mistake here this will
be a small T and small p now that we did
that get a property for type and genera
property full price now let's just close
this column there we go so we are
creating a new book this book if I hit
ok let's go to definition you can see
the book class now has all these
attributes this properties and now what
we want is to return these books this
book's variable but convert them into a
list so we to do list and that's it this
should be working now and but just a
small a small addition let's do this ok
and let's open this a little bit you see
this application configuration file this
one a has the connection string and for
this test for the test around we will
have to add a new configuration file
into the test project let's add sorry
let's right click and add new item and
in this list let's use application
configuration file so this is the
configuration for the test let's copy
the connection string and place it here
and that's it if we go now to our test
class right click and hit run tests okay
the test will be wrong this time using
our brand new implementation and as you
can see we get ring so the test is now
passing very easy final task as we have
already finished this let's right click
here and we need to add this search into
source control so they we just hit
check-in let's say
get book list method implemented okay
you see this is all the source that you
are chicken in and a good practice
always always go to work items and
select the work item that you are there
is related to this check in get it is
very important for tracking layering the
in the project so build the book list
screen check here okay as this is not
really resolving all the all the task so
we will just associate it at the cds for
for this time so let's hit check-in ok
so that's it
No comments:
Post a Comment