"niberhate" <> wrote in message
news:b9d08c4c-c61a-4008-8bd1-...
On Mar 3, 8:39 pm, "Scott M." <s-...@nospam.nospam> wrote:
> "niberhate" <gnewsgr...@gmail.com> wrote in message
>
> news:35640fec-ff14-4a1d-806b-...
>
> >I am working on an existing asp.net website project (not a web
> > application project). I want to add a unit test project to the
> > solution, but I don't know how to reference this website project in my
> > unit test project.
>
> > It is easy if it were a web application project because I could select
> > from the project tab. This website project does not show up in the
> > project tab. I am talking about the project tab in the Add Reference
> > dialog box.
>
> > Any idea? Thanks.
>
> You'll only be able to unit test the code in the App_Code folder and
> you'll
> need to pre-compile the web site so that the code in this folder gets
> compiled into a .dll. Then you can use the "Browse" tab of the Add
> Reference dialog to browse for this .dll.
>
> This is part of the price you pay with website projects...their code is
> dynamically compiled at runtime. Microsoft and many book and article
> authors like to talk a great deal about websites, but the reality is that
> for large-scale mission-critical applications, ASP .NET Web Application
> Projects are much preferred.
>
> -Scott
>So, looks like Website project is really bad for those who do TDD's.
>Can we precompile the Website project and then refer to the resulting
>dll outside of this Website project?
The only benefit of a Web Site is that you don't have to worry about all
your code having to compile into one .dll. They were invented for those
developers who wanted a finer level of granular control over the files and
assemblies in their work. But, the ramifications of using them make them
not very suitable for business application development. I don't know of any
company using them for Enterprise development. There was such a backlash
from developers when VS 2005 initially shipped without the Web Applicaiton
Project type and only the Web Site, that MS put it back into VS 2005 SP1 and
then VS 2008 and VS 2010.
If you do precompile your App_Code folder's stuff into a .dll, then you can
use the Browse tab of the Add Reference dialog to reference it from any
other project. But, if you are going to need this functionality in other
places, you may want to consider making a stand-alone class library or
component that can be used in both projects.
-Scott
|