title: How to test switch, which depends on property without setter?
body: <p>For example I have <code>SomeClass</code> class which implements <code>ISomeInterface</code> interface with two properties <code>Prop1</code> and <code>Prop2</code> (<code>Prop1</code> has NO setter!!! and <code>Prop2</code> depends of <code>Prop1</code>):</p>
  
  <pre><code>public class SomeClass : ISomeInterface
      {
          private readonly NameValueCollection settings = ConfigurationManager.AppSettings;
          private readonly string p1;
          private string p2;
  
          public string Prop1 { get { return settings["SomeSetting"]; } }
          public string Prop2
          {
              get
              {
                  switch(Prop1)
                  {
                      case "setting1": return "one";
                      case "setting2": return "two";
                      case "setting3": return "three";
                      default: return "one";
                  }
              }
              set { p2 = value; }
          }
      }
  </code></pre>
  
  <p>I need to write unit tests for this class. I suggest they should look like:</p>
  
  <pre><code>[TestMethod]
  public void Prop2ShouldReturnOneValueIfSomeSettingEqualsSetting1()
  {
      var someClass = new SomeClass();
      Assert.Areequals(someClass.Prop2, "one");
  }
  
  [TestMethod]
  public void Prop2ShouldReturnTwoValueIfSomeSettingEqualsSetting2()
  {
      var someClass = new SomeClass();
      Assert.Areequals(someClass.Prop2, "two");
  }
  </code></pre>
  
  <p>So my question is: <code>How can I force Prop1 return setting1, setting2 etc. if it has no setter?</code> I cannot set the values I need to fields because they are private. Should I mock <code>ISomeInterface</code> or <code>ConfigurationManager</code>??? If so, how can I mock <code>ConfigurationManager</code> if it has no interface??? Should I mock directly <code>ConfigurationManager</code> class??? Will it be right??? Also I don't understand how can I mock <code>ISomeInterface</code>. I need to test <code>prop2</code> which depends on <code>prop1</code>. If I type:</p>
  
  <pre><code>[TestMethod]
  public void Prop2ShouldReturnTwoValueIfSomeSettingEqualsSetting2()
      {
          var moqSettings = new Mock&lt;ISomeInterface&gt;();
          moqSettings.Setup(p =&gt; p.Prop1).Returns("setting2");
  
          ...
      }
  </code></pre>
  
  <p>it will not change anything, because <code>moqSettings.Object.Prop2</code> will be <code>null</code>. And, I'm not sure, but I think it's wrong to do like that))) <code>So how can I test all cases in prop2???</code></p>
  
  <p>P.S. For mocking I use <code>Moq</code>.
  P.P.S. Sorry for my English))) I hope I explained clearly what i need...</p>