Winforms - NUnit (2.5) Windows Forms Testing ?

Jun 10, 2012

I am retrofitting unit testing into a fairly complex system designed and written by other developers in VB.net. I am trying to develop unit tests for the GUI forms using NUnit and the NUnit Forms extension. (I've been looking at c# examples that are fairly easy to port over if you have a solution but don't know VB syntax as long as it uses NUnit classes)I will try and explain what I am doing but first a brief description of the program. It basically monitors server activity. You need to connect to a server via a modal form with IP and Port fields(amongst others). Once you have connected to a server other parts of the program unlock and become usable (such as configuration of the server).Desired process: Load program > click connect button > modal connect form loads > enter details > click OK to connect > main form updates to logged-in state > other functionality

The problem is that I cannot test the functionality of the connect form and then the logged-in functionality of the program. I can test that it loads the modal connect form correctly; enters the details and clicks OK (all fine so-far) but it does not appear to logically progress the program. The modal form just closes again seemingly without running the connect code from the program back-end and I'm back at the main menu not logged in to anything. I have a feeling that I've either missed something really obvious or that it's simply not doable in NUnit. I have trawled the internet in search of anything similar but the closest was another SO thread that was really generic. Without being able to actually test the logged-in version of the program, I'm at a major hurdle.Another issue is handling message boxes that don't have unique identifiers (e.g. "are you sure you want to exit?"); these also seem to be a major pain in the arse with NUnit(If it makes any difference, I'm running the tests as a stand-alone project using a reference to the executable file of the built project, not the actual source)

View 1 Replies


ADVERTISEMENT

Winforms - .net NUnit (2.5) Windows Forms Testing?

Oct 18, 2011

I am retrofitting unit testing into a fairly complex system designed and written by other developers in VB.net. I am trying to develop unit tests for the GUI forms using NUnit and the NUnit Forms extension. (I've been looking at c# examples that are fairly easy to port over if you have a solution but don't know VB syntax as long as it uses NUnit classes)

I will try and explain what I am doing but first a brief description of the program. It basically monitors server activity. You need to connect to a server via a modal form with IP and Port fields(amongst others). Once you have connected to a server other parts of the program unlock and become usable (such as configuration of the server).

Desired process: Load program > click connect button > modal connect form loads > enter details > click OK to connect > main form updates to logged-in state > other functionality

The problem is that I cannot test the functionality of the connect form and then the logged-in functionality of the program. I can test that it loads the modal connect form correctly; enters the details and clicks OK (all fine so-far) but it does not appear to logically progress the program. The modal form just closes again seemingly without running the connect code from the program back-end and I'm back at the main menu not logged in to anything.

I have a feeling that I've either missed something really obvious or that it's simply not doable in NUnit.I have trawled the internet in search of anything similar but the closest was another SO thread that was really generic. Without being able to actually test the logged-in version of the program, I'm at a major hurdle.Another issue is handling message boxes that don't have unique identifiers (e.g. "are you sure you want to exit?"); these also seem to be a major pain in the arse with NUnit (If it makes any difference, I'm running the tests as a stand-alone project using a reference to the executable file of the built project, not the actual source)

View 2 Replies

Difference Between NUnit Testing And Unit Testing In VSTS?

Aug 25, 2009

I use VS team system 2008. At the moment i need to test some business classes, i have found two kinds testing NUnit and the unit testing provided by the VS team system. what are there differences?

View 1 Replies

.net - NUnit Tests For Testing Class-level PrincipalPermissionAttribute Demands

Mar 1, 2012

I'm working with .NET 3.5 and Nunit 2.5.10. I'm attempting to write some tests to validate our role-based security enforcement through the PrincipalPermissionAttribute at a class-level. The test appears to succeed (it gets a green checkmark) and the Assert.Throws call properly catches the exception, and all my other assertions about the exception pass. However, once TearDown is complete after a test has run, the exception is re-thrown by NUnit. So even though the test "passed", every one of the tests shows that an exception was unhandled exception was thrown 'while executing' the test run.

I'm guessing I'm doing something wrong, but can't figure it out. My test is:

Public Sub New_TheForm_NoRoles_DeniesAccess()
' attempt to create a new instance of the form, but it should throw an exception with an inner SecurityException
Dim ex As TypeInitializationException = Assert.Throws(Of

[Code]....

Basically, Initialize is normally called in the application with Nothing so that we use the Windows Principal. During unit testing, we instead initialize it with a GenericPrincipal that has no roles, so that we can test that a SecurityException is thrown.

The tests are passing, but NUnit just seems to be re-throwing the exception post-Teardown.

View 2 Replies

.net - NUnit Testing Show A Form And Populate Its Textbox From Dataset In TestClass

May 20, 2011

I have written my and in a test class for vb.net and it works as follows:

A stored procedure is executed and the result is saved in an xml file with the help of a dataset. What I need to do now is , Information of this dataset should also be redirected to a textbox in a form so that I can copy this information in clipboard and create dynamic assert statements for instance I want

datatable.rows.count,
datatable.columns.count,
datatable.columns(i).ColumnName,

and same to get columnType. All of this info would be shown in the form but I am unable to open a form in NUnit test class.

View 2 Replies

Winforms - How To Load Binary To Windows Media Player In Windows Forms

Jul 24, 2011

I've successfully saved video files into SQL server as varbinary. Now, my problem is, how can I play those videos in Windows Media Player (embedded in my Windows Forms).

View 1 Replies

Winforms - TextBox Validation In .NET And Windows Forms?

Mar 5, 2009

I'm using the following code to validate the text entered by user. It works perfectly fine. But I want to add the backspace feature so as to allow the user to delete the wrongly entered number.I have tried a couple of things and they worked but before last digit (after the decimal point) i.e. it does not allows to delete after the number has been completely entered.number is being entered in the format: 12313213.45

What shall I do?Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress

[Code]...

View 7 Replies

Winforms - Word Wrap In Windows Forms (.net)?

Apr 25, 2009

how to do word wrap in drawstring in vb.net 2005.

View 2 Replies

Winforms - Where And When Is InitializeComponent Called In Windows Forms Control

Jun 25, 2009

In C# Windows Forms, a user control's InitializeComponent is called from the form's/control's constructor. When I create same scenario in VB.NET I don't get a constructor, and I can't locate a place where InitializeComponent is called.I need to call my code between InitializeComponent and when the control's Load event is raised, preferably still in the control's constructor. How do I do this in VB.NET?

View 2 Replies

Winforms - Controls Based Security In A Windows Forms Application Using .NET?

Sep 5, 2011

I need to implement, Controls Based Security in a Windows Forms Application using VB.NET. I tried google but did not get anything much to work with.

I would like if someone, could suggest some books or tutorials.

View 1 Replies

Winforms - .NET 2.0 - StackOverflowException When Using Thread Safe Calls To Windows Forms Controls

Sep 22, 2011

I have a Windows Forms app that, unfortunately, must make calls to controls from a second thread. I've been using the thread-safe pattern described on the [URL].. Which has worked great in the past.

The specific problem I am having now: I have a WebBrowser control and I'm attempting to invoke the WebBrowser.Navigate() method using this Thread-Safe pattern and as a result I am getting StackOverflow exceptions. Here is the Thread-Safe Navigate method I've written.

[Code]...

View 1 Replies

Winforms - Grouping Controls In Pairs Windows.forms - Dynamic List In Grid Format?

Sep 8, 2010

I have pairs of controls: immagebox + textbox = one pair.I want these to show up in a single column grid/tabular format.Each cell contains one image/text pair.I want this grid to scroll because the number of pairs is dynamic depending on a user selection.I suppose I will be adding these controls in code at runtime when the user makes his/her selection.

View 1 Replies

Testing In Under Windows 7?

Nov 25, 2009

When i try to run my unit tests in vb.net, visual studio closes down because of an error.I don't know what is causing the problem but i is very frustrating.I have a project running for school that i can't continue because of this problem.When i had visual studio installed under windows vista i didn't got that problem. (same version of visual studio)

View 8 Replies

Testing A Windows Service?

May 15, 2012

1. when testing a service, should I install the exe which is in the bin subfolder or the obj subfolder, and why?

2. when distributing the service, should I use the exe which is in the bin subfolder or the obj subfolder, and why?

View 3 Replies

Sql - Unit Testing The Data Access Layer - Testing Update Methods?

May 15, 2009

I'm looking into adding some unit tests for some classes in my data access layer and I'm looking at an update routine that has no return value.It simply updates a row based on the id you provide at whichever column name you provide.Inside of this method, we collect the parameters and pass them to a helper routine which calls the stored procedure to update the table.Is there a recommended approach for how to do unit testing in such a scenario?

View 4 Replies

Windows - Testing Application For Administrative Running Rights .NET?

May 23, 2011

I want a sure-shot method to test if the application was run via the UAC box and has full administrative rights. Earlier, I thought of making a folder in C:Windows for testing but running it on other computers proved to be a failure!

The UAC box provides all administrative rights to the computer to do anything(including making folders and creating files in places which needs there rights) and also makes sure that any child program so called or created also does have the same rights as the parent.Is there a sure-shot way to test if my application has been provided all the administrative rights that I can maximum get by the user while running the application or not? If yes, I would be glad to have to piece of code-work!

View 1 Replies

Developing On2008, Windows 7 X64, When Testing On 32-Bit XP, Apps Get Error Code?

Dec 7, 2009

alguien habla español

View 3 Replies

.net - Unit Testing C# InternalsVisibleTo() Attribute For NET 2.0 While Testing?

May 13, 2010

I'm building an Active Directory wrapper in VBNET 2.0 (can't use later .NET) in which I have the following:

IUtilisateur
IGroupe
IUniteOrganisation

These interfaces are implemented in internal classes (Friend in VBNET), so that I want to implement a façade in order to instiate each of the interfaces with their internal classes. This will allow the architecture a better flexibility, etc.Now, I want to test these classes (Utilisateur, Groupe, UniteOrganisation) in a different project within the same solution. However, these classes are internal. I would like to be able to instantiate them without going through my façade, but only for these tests, nothing more.

[Code]...

View 1 Replies

Operator '*' Is Not Defined For Types 'System.Windows.Forms.VscrollBar' And 'Systems.Windows.Forms.VscrollBar

Oct 29, 2011

I am trying to use values from form1 in my project, in form2, but Im not sure how to do it. I've tried

txtboxTotal = (Form1.vsbLength * Form1.vsbWidth) * Pattern

But I get: operator '*' is not defined for types 'System.Windows.Forms.VscrollBar' and 'Systems.Windows.Forms.VscrollBar.'

View 14 Replies

Forms :: Delete Cookies In Winforms?

Nov 27, 2009

I've been trying to know how to delete all the cookies of a domain, created by using the WebBrowser control.I know that to invalidate a cookie, it's necesary to set its expiration date in a point of the past (a negative value), but all the information I found is for web developing aplications, and I'm using a form.

View 4 Replies

Forms :: Using Large Database In WinForms?

Dec 27, 2009

I am currently helping to write a Visual Basics program that was originally writing with access.The Original Access program has been used and modified over the past 5 years, During that time the database has gotten pretty big.The problem I am having is If I add the entire database to my data sources it creates data tables for every Table and Stored procedure even when they are not currently used in the program resulting in a 20+ minute build time just to debug.I am currently only adding Tables and Stored Procedures as i need them, so its not that much of a problem now, but as I continue to work and add tables the build time is going to go back up, and Id hate to have to wait 20+ minutes to test a small tweak I made.

View 1 Replies

Forms :: VS2010 WinForms Labels?

Nov 4, 2011

I have a label that displays text kinda like a title to something (autosize = falseTextAlignment = MiddleCenter) and whenever the label control isn't wide enough to display the single line of text it tries to auto-wrap it causing half of the text to be chopped off at the top and half of it chopped off at the bottom. I would rather it stay on a single line and cut the text off from the right

View 1 Replies

Have Forms In Sub-namespaces Of A WinForms Project?

Oct 15, 2010

If I create a new class library project in VB.NET, I can create subfolders (a la C#), add WinForm objects to these subfolders, and then specify a namespace:

Namespace Sub1.Sub2
Public Class SomeForm
Public Sub New()
InitializeComponent()

[code]...

This resolves as ProjectRootNamespace.Sub1.Sub2.SomeForm, which is good.However, if I create a new WinForms project in VB.NET, and attempt the same thing, I get this error in the designer:The class SomeForm can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.Is there a way to have forms in sub-namespaces of a VB.NET WinForms app instead of in the root namespace?

View 1 Replies

Winforms - Custom Constructors For Forms In .net?

Nov 1, 2010

I would like to open a new form from some other form, and pass some selected object from a control on that form to the new form. The sensible way to do this, I thought, was as a parameter to the forms constructor. Now I know that the visual studio GUI creates partial classes for my forms, that hold the properties that I can drag onto there in the designer. I assume it also holds a default constructor. Since it might do all sorts of stuff that is needed to initialise the form, I figured I should call it from my custom constructor ala

public sub new(byval my_parameter as Foo)
Me.new()
Me.my_parameter = my_parameter

[code].....

That clearly wasn't it, because it can't find a default constructor. The thing is, visual studio goes trough great lengths to prevent me from seeing the generated constructor, so I know how to access it. This leads me to believe that I am actually doing it wrong, and should have set out on some different path, as the path you are forced in to usually is the sensible thing to do, which I usualy find out way too late.

View 3 Replies

Winforms - Friend Vs. Public For .net Forms?

Jan 19, 2010

Is it better to use friend or public forms in vb.net? What are the advantages of each?I notice when you import a vb6 project, the forms come in as friend, but when you add a new form in vb.net it is public. I have not seen any difference in the way they work, though, so I must be missing something.

View 3 Replies

Winforms - Passing Values Out Of Forms?

Sep 8, 2011

I have a very simple windows forms setup. Form1 has a progress bar and a button on it, when clicked the button opens Form2 which also has a button on it that launches Form3. On Form3 is a button which I want to use to raise an event back to Form1.To achieve this can I add an event handler on form1 that will listen for an event of the type raised in form3? Or do I have to pass references to form1 to form2 and then from form2 to form3?

View 1 Replies

Winforms - Unload All Open Forms ?

Feb 26, 2009

In the middle of converting VB6 code to VB.NET, I need to replace the following code that intends to close all open forms remaining in the application.

'close all sub forms
For i = My.Application.OpenForms.Count - 1 To 1 Step -1[code].....

I've replaced the Unload function with Close (as indicated by TFM), but the compiler complains that OpenForms is not a member of My.Application.Where can I access the open forms?

View 4 Replies

Implicit Conversions From 'System.Windows.Forms.Control' To 'System.Windows.Forms.Webbrowser'

Sep 8, 2010

I have the code which checks if there is a selected tab

Private Function GetBrowser() As WebBrowser
If TabControl1.SelectedTab IsNot Nothing Then
For Each c As Control In TabControl1.SelectedTab.Controls
If TypeOf (c) Is WebBrowser Then
Return c

[Code]...

View 2 Replies

.net - Gotfocus() Mdi Child Windows Winforms?

Jul 13, 2010

I have a mdi and 3 child windows.The program start with an empty mdi.With a menu you can open each child window once.When i open for example 2 windows. And close the one on top. The one left(the window under the one i closed) should get focus. How can i manage this?

why i need this?each childwindow has a event gotFocus. Depending on the focus my menu should change.

Private Sub frmMain_gotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.GotFocus

View 2 Replies

.NET Winforms App Under Windows 2003 Server

Jun 29, 2009

.NET Winforms App Under Windows 2003 Server

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved