How do I coordinate settings between my ASP.NET MVC 3 app and SpecFlow? - asp.net-mvc

So I have a VS 2010 solution containing one ASP.NET MVC 3 project and one SpecFlow project (with NUnit as test runner) to test the former. When testing under SpecFlow (by running the SpecFlow project), I'd like to change a parameter in the MVC application's ConfigurationManager.AppSettings dictionary, to make it connect to a test database. This change does not seem to affect the running app however, so I guess the test and the app do not share state.
How can I share this application setting between the MVC app project and the SpecFlow project, so they use the same database?
Edit:
I found that the problem wasn't really one of sharing settings between projects (MVC and SpecFlow), but rather between two processes. The reason is that I test MVC via WatiN, which means that the development server, running in a process of its own, is being exercised by the tests. As such the premise of my original question was wrong from the onset, and I consider Jason's answer valid given the original premise.

In your test project (SpecFlow) create a new app.config (unless it's already there) and add the appSettings section to that, with your test database connection string. IIRC the website will hopefully pick up the connection string from the appSettings of the test project, rather then the website.

Related

How to debug Web API through a separate Web project on same machine?

I'm taking over a project from someone who is no longer avaiable to ask how/why their prjoect works.
I have two solutions, one a MVC project and the other a Web API. The MVC project calls the separate API solution to do some validation of data. If I start up the Web API project it runs on localhost:64633. Then I need to start up the MVC project so that I can step through the code and all the way through the Web API.
Thing is that the MVC project runs on localhost:64633 as well so once I have the API running and then try to debug the MVC project I get an error "Unable to start program localhost:64633. An operation is not legal in the current state.".
How can I debug both the MVC project and Web API project at the same time?
Run Your project using local IIS server, follow below steps for that
Right click on project file choose property
Go to Web tab, under the Servers header choose Local IIS
Then click "Create virtual Directory" button
Do above steps to both project. please try now
Note : Run both project with in single solution, automatically debug both project at a time.(Just suggestion only)

Updating EntityFramework project to new environment

I'm not sure exactly how to word this question. Whenever I am publishing an entity framework application from Dev to Test and then to production I've always just changed the connection strings located in the app.config or web.config and then updated my .edmx from those dbs (update from database option). Then did my publish or build and move the files over (from my dev machine).
However, I'm not sure that this is necessary or the correct way of doing it. Is there a better/correct way of doing this?
And if it is a term that I can just lookup, let me know that. I can do the research I'm just not sure how to word it.
In the project(asp.net MVC) it is using Entity Framework 6.

TFS 2012 - Continuous integration with a website

I have a solution with multiple C# projects linked to a Website (File => New => Web Site).
I can use the continuous integration for all the C# project for now.
I would like to try the website from a different solution just for testing:
I would like to know if the modification of an aspx or aspx.cs file will
rebuild all the solution/project or just push the file which was
modified on Azure.
It seams that the website will be rebuild, or will try to rebuild.
Here is my website test solution
and my Build Definition file :
So my question is, is it possible to integrate a website to a continuous integration system ? (TFS 2012)
If it's possible, What did I miss on the basic configuration ?(I didn't need any specific configuration for a WebApp project or a C# project)
I might need to build some files on the website (App_Code folder), But I would keep the possibility to deploy only the modified files (aspx, aspx.cs) without rebuild all the website and push everything on the server.
Let me know if you need any further information
There is an article here Continuous Deployment di Asp.Net web sites con TFS Build. It is in italian, but I think you may get the core using Bing/Google translator.

How to configure an ASP.NET MVC application with Test and Release-Version strategy

I have no clue how to configure my ASP.NET MVC3 Application to work in at least two different buildversions.
What I would like to achive is a release version that's used by my customers with an database that holds their realtime data. Further more there should be at least one additional release version for testing purposes, connected to another database using test data.
Environment:
ASP.NET MVC 3
Entity Framework 4
VisualStudio 2010 Pro
MSSQL Server 2008
IIS7
If you start a MVC3 project you should already have 2 build web.config files: debug and release. In these files you will define your database connection. Now you can create your own build profiles through the "Configuration Manager" for developer, test, accept and release environments.

What should I store/ Not store in TFS and how?

I'm trying to set up a TFS server for our small dev team, and since this is fairly new to me I have a couple of questions.
1) We are developing ASP.Net websites for internal use (intranet etc), these websites currently are not saved with visual studio solutions, they get saved basically as they are on the server and we just update them using Visual Studio by doing file > open website.
So my first question is should I save these as solutions in TFS? What would the benefit of this be?
Im coming from a background of developing WPF applications and have always seen everything saved with a solution in TFS.
2) What should we store in our TFS repository (and what should we exclude)?
At the moment I am storing source code & Documentation but is it really appropriate to store things like installers for VS plugins / small applications or should this kind of thing all be placed on a server someplace?
So my first question is should I save these as solutions in TFS? What
Yes, you could create a solution containing the different ASP.NET web applications.
would the benefit of this be?
Your source code will be version controlled
What should we store in our TFS repository
Source code, third party assemblies that your ASP.NET applications might require, script files, basically everything that allow to get your site up and running. Documentation should also be stored along with the project. Same stands for installers (the source code only, not the MSI) if those installers allow to deploy the ASP.NET application on the live servers.
and what should we exclude
Compiled assemblies, but they are automatically excluded by TFS anyway.

Resources