I implemented a C# user control and succesfully tested it with the UserControlTestContainer.exe by manually interacting with it. Now I would like to programmatically, instead of manually, feed data into the control, through my unit tests and then automatically display the control filled with that data. I guess I need to create an instance of the control, fill it up and then programatically start the container with the control as parameter, don't I? How do I succeed displaying my filled control? The solution doesn't have to involve the above mentioned container of course, any other suggestion to get the work done would be very appreciated.
I just created an other "Unit Test" project doing all UserControlTestContainer work. UserControlTestContainer is started through the external application option on the project's properties.
Related
I'm starting a project which will contain multiple pages tabs style. I.e. you have a footer of the application and it's header. Header contains buttons that load different User Controls in the center of the app. I know how to swap user controls and show one or another, but, what concerns me are events from hidden controls and UI updates.
I was thinking about creating UserControls to represent each page. One would contain list of files available for download, another would contain UI of the download manager that would show end user progress of download.
In order for some page/control, that is not currently showing, to throw events, its instance need to be present. What would happen with UI updates in this case? Consider user selected files to download and added them to the download manager. Download manager is currently in the "background", basically, it's UI doesn't exist (instance of the UserControl exists though). I presume that every attempt to update the UI will end up with an error?
Or, am I over-thinking this? Now, that's all a theory at the moment, I didn't yet code a single line of code for this project because I wanted to consult with someone and start from the right foot.
Thank you in advance.
P.S. Or may be use tab control...
If I understand you correctly, you are not loading/unloading the usercontrols, but merely showing/hiding the usercontrols. Updating the UI should not cause an error in this case. What you need to the design and implement is a number of events that the container will subscribe to. The container should then trigger funtion calls to the correct usercontrol that needs to be updated. But, as you state I would prefer to use a tab control. But, the event part is still the same.
I have a question about Coded UI and how to best use it together with others. We are a team(of 3) who are testing a large web application(which is hard by itself) but we also want to make all the tests in one solution and share that solution through GIT(or TFS). What is the best way of doing this?
We have tried a few things already. We tried using the default UI map, but this creates a lot of merge conflicts and the UI map class becomes long and hard to understand.
We also tried using different UI maps for every page on the site. This seemed like a good idea since we all could test different parts of the website. The problem with this was that once you created one UI map and mapped the content of that page, you could not go back to mapping against that UI map again. So if we had mapped one page and then written a few tests and then some functionality was added, we could not go back to map this. If we created a new test and mapped through this test, this mapping was added to the default UI test. I think this method would work if we could just change which UI map the code would be added to for a new test.
Any reply would be appreciated!
To record and add new methods and controls into a UI Map other than the default, right-click on the UI Map's .uitest file in solution explorer and select the "Edit with Coded UI test builder" menu entry. By contrast, if you right-click in a method within the test sources and select the "Generate code for Coded UI test" menu entry then it will write to the default UI Map; creating it without warning if it does not exist. See also this Visual Studio user voice entry http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3378897-choosing-the-uimap-when-recording-tests
I am sure you`ve read this one: http://msdn.microsoft.com/en-us/library/ff398056.aspx
In case of my app with similar issues we`ve got rid off UI Maps and hand code everything, wrap it in methods and make is as reusable as possible.
I'm creating an application that has to handle the construction cases of a small company. In order for the employees to create a new case, I want to put them through a step-by-step process. How do i setup up such a process?
I've tried putting them on panels instead, but this still seams like a not so elegant way to solve this problem.
Right now i'm hiding/showing lots of textboxes and listboxes individually. Is there some smarter(more correct) way to group these. Or could someone suggest another approach to this? I'm building it in c#.
The best way i have used in this scenario is to create all your Buttons, Textboxes, etc for one step in a UserControl and do the same for each step and better embed all your code specific to that step in that control itself.
On Form only keep those controls which are Universal for every Steps. Then have a container control like a Panel on the form as a Placeholder (so that you don't have to worry about positioning ..however you can even in code set the Location of the Control on Form and directly Add it to Form's Controls Collection)
Then on first step create a new instance of UserCotrol for Fisrt Step and add the first UserControl to the Forms Control Collection or that Container Control (Panel) and on next step Remove it and Replace it with Next UserControl.
This way you wont have all controls in the Memory all the Time and they will be created when required and Disposed when not required. Its Efficient and also isolate each step so you have manageable code for each step.
What about creating a Wizard for it? Hope the following links also helps you.
What is the best way to create a wizard in C# 2.0?
Creating Wizards for Windows Forms in C#
Creating Wizards for Win Forms in C#
How could you create an application that could search through a directory, find user controls in the form of paired .xaml / .xaml.cs files, and compile/execute these on the fly? Is this possible? Is there an .exec() or .compile() class somewhere that could do this?
Basically what I want to do with this is have a WPF application that is running and by having the user fill out a form describing the kind of page/functionality he wants, the application could generate XAML and code behind files which are then immediately usable without having to recompile the application.
I'm assuming that this is to change the behaviour of the UI on a known application rather than a XAML/CS component generator for use in another application - after all there's already applications that do this - Expression Blend anyone?
Do you really need to recompile the underlying CS? As far as I can see it all you'll be doing is changing the apparent behaviour and look of the application and UI. This could be achieved by command binding within the xaml and styles for the components.
The reality is that in order to perform the functionality that you require you'll be giving the user a finite choice as to behaviour. You'll need to decide what behaviour is application and what is the UI.
Application bahaviour is governed by fixed commands (they could accept parameters to change behaviour).
UI behaviour (appearance, animation etc) is covered by the xaml. If the application runs in a browser window you could auto generate the xml needed as requried, linking it to the underlying app. commands and allow the browser to execute the new behaviour for you.
Is this a good idea? I can see a few problems with this.
How will the code behind 'know' how to interact with the rest of the application
Security? You will be allowing somebody to make system API calls on behalf of the main application
App domains???
Rather build up the forms using ItemsControls and DataTemplates. In the form where the user specifies what functionality he wants in the form, you will be presenting him with a list of 'building blocks' anyway. Make each 'building block' a ViewModel and associate each ViewModel with a DataTemplate 'UserControl'.
I've been writing some small maintenance/viewer tools that each connect to a SQLServer (2005) database via System.Data.SqlClient classes.
(C# - .NET 3.5 - Windows.Forms)
For each of these tools I had to write the UI and dialog to let the user choose the right db and server: I connect to my test-db, my colleague uses my tools too and connects his test-db.
I'm looking for a plugable usercontrol that lets the user select a server, db and the rest of the connection parameters and that provides a SqlClient.SqlConnection to the rest of the application.
I've tried writing a usercontrol myself now, but I'm sure there must be others ,better ones and better tested ones. I've been Googling and looking at CodeProject, but found none.
There must be some better than one I wrote recently, because that one's so bad:
Just
Create a user control
drag a couple of buttons to it, anchor bottom center, make them ok and cancel
drag a Property Grid control onto it, dock fill
Add a read-only property to the control of type SqlConnectionStringBuilder, back it with a field
Initialize the field to a new SqlConnectionStringBuilder instance
In the Load event, set the Object property of the property grid to the SqlConnectionStringBuilder
That's pretty much that. The user just gets to fill in the properties. If you like, you can also create a ConnectionString property on the control and have it return the .ConnectionString property of the SqlConnectionStringBuilder.
What you're describing here is simple enough that I doubt there's something out there that does only this. You'd probably be better off sticking with your own code here.