Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
225 views
in Technique[技术] by (71.8m points)

c# - Is it possible to configure a .net runsettings file to include complex objects?

I'm looking at implementing a runsettings file for automated testing. Thing is, my variables are complex objects, and all I can find in the documentation about runsettings has simple key/value options, like so.

<TestRunParameters>
  <Parameter name="webAppUrl" value="http://localhost" />
  <Parameter name="docsUrl" value="https://docs.microsoft.com" />
</TestRunParameters>

I'm wondering if it's possible to specify a complex object like you might specify below (especially since TextContext.Properties returns an object, so I assume it's polymorphic in some sense?) and cast it to a given defined class

<TestRunParameters>
  <Parameter name="AdminUser" UserID="Admin" Password="P@55w0rd!" />
  <Parameter name="User" UserID="User" Password="P@55w0rd!" />
</TestRunParameters>

I realize I can do the below and manually create my object instances, but I'd really really like to avoid it if at all possible

<TestRunParameters>
  <Parameter name="AdminUserID" value="Admin"/>
  <Parameter name="AdminUserPW" value="P@55w0rd!" />
  <Parameter name="UserID" value="User"/>
  <Parameter name="UserPW" value="P@55w0rd!" />
</TestRunParameters>
question from:https://stackoverflow.com/questions/66052899/is-it-possible-to-configure-a-net-runsettings-file-to-include-complex-objects

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...