Odpovědět Scaffolding properties on object/input

  • 29. února 2012 0:26
     
      Obsahuje kód

    Is there a way (via Visual Studio add-on or an extension) to automatically expand properties of an complex type that is used to feed input into a method call under test.

    [TestMethod]
    public void TestMethod()
    {
    	var foo = new Foo
            {
    		Property1 = 3,
    		Property2 = 1.68m,
    		Property3 = EnumValue.Value1,
    		Property4 = new Bar
    		{
    			PropertyB1 = 1,	
    			PropertyB2 = "test",
    		},
    		Property5 = "Abc"
    	};
    	var restult = Method(foo);
    	Assert.AreEqual(1, restult);
    }

    Visual Studio Unit Test Wizard does create a TestMethod scaffolding; but leaves complex types will a null assignment.  It would be desirable to have all the properties written out; such that only the values then would have to be typed in.

Všechny reakce