Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7872195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:08:06+00:00 2026-06-03T02:08:06+00:00

I currently have 2 projects, one is a standard ASMX web service and the

  • 0

I currently have 2 projects, one is a standard ASMX web service and the other is a test project. The web service project has a Web.config file that contains my connection string. I’m aware of how to change the connection string to qa or production. My issue is that I’m unsure how to change the connection string for my tests project. What I want is to use SQLite for tests.

Here is what my targets file looks like that I added to my tests .csproj file.

<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <ConnectionString>Data Source=:memory:</ConnectionString>   
    </PropertyGroup>

    <Target Name="BeforeBuild"
        DependsOnTargets="Clean" />

    <Target Name="AfterBuild"
        DependsOnTargets="UpdateConfigFileForEnvironment" />

    <Target Name="UpdateConfigFileForEnvironment">
        <PropertyGroup>
            <AppConfigFileName>$(OutDir)Web.config</AppConfigFileName>
        </PropertyGroup>

        <FileUpdate
            Files="$(AppConfigFileName)"
            Encoding="ASCII"
            Regex="ConnectionStringBuild"
            ReplacementText="$(ConnectionString)" />
    </Target>
</Project>

And here is the Web.config file in the web service project. I omitted the majority of the content as it’s irrelevant.

  <appSettings>
    <add key="ConnectionString" value="ConnectionStringBuild" />
  </appSettings>

The issue when I run my unit tests via ReSharper in VS2008 getting the AppSettings entry ConnectionString nothing is returned. Also, if I run msbuild in the command line on my test project the connection string successfully gets updated.

How can I modify the connection string when running tests?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:08:07+00:00Added an answer on June 3, 2026 at 2:08 am

    You should structure your data access classes in such a way that you pass a connection string into it as a dependency (see Configuration Settings are a Dependency by Paul Hiles).

    This will allow you to pass in a different connection string in your test code from the one in configuration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a solution that contains two projects. One project is an ASP.NET Web
Currently I have a simple maven project that is building a jar file and
I currently have the following in one solution: Core Project (data access, biz logic,
I currently have a file abc.htm in my Custom Server Control Project and it's
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
Currently we have a project with a standard subversion repository layout of: ./trunk ./branches
I'm trying to write a project that will have some autonomous components. One of
I have recently started work on a project that has already been running for
I currently have a single solution that contains both the one application developed so
I have a project which builds correctly from the command line. On one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.