Unit Testing For Invalid Enum Value
Jun 5, 2009
I have a lump of code that looks a bit like this:
If mode = DiaryMode.Admin Then
modeObject = DBNull.Value
ElseIf mode = DiaryMode.Academy Then
modeObject = ApplicationSettings.Academy
ElseIf mode = DiaryMode.Scouting Then
modeObject = ApplicationSettings.Scouting
Else
Throw New NotSupportedException()
End If
The idea of the check is to prep some values for passing into a database call. There are two questions, is the Else worth the effort? The intention is to prevent future extensions of the enum causing the code to return squify results. If the code is valid, I'd like to be able to unit test the behaviour, if it's worth having it's worth testing. How might I go about doing that?
View 3 Replies
ADVERTISEMENT
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
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
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
Dec 29, 2010
I have been assigned a task of exploring unit testing using tools available in the market.My question is how do i write an API that would help in writing unit test cases.Example i can use nunit to write something like this to check whether file exists in the given location.
<Test()> _
Public Sub CheckOutputFileInfo()
ReportPath = "D:temp est.txt"
[code].....
View 3 Replies
Aug 29, 2009
In the project that i;m currently working on i;m not allowed to touch GUI for anyreason that includes program testing. I'm in bit of s frustration becuase prior to this all must application were developed and tested using GUI. Typicvally it wold take a me a week to develop an app now it taking more than that. Especially the TDD with Unit testing. The documentation kills more time too......
View 4 Replies
Apr 28, 2009
I really like the moq mocking framework. I've used it on several projects. Unfortunately, one of my customers is demanding we use VB.Net. Not my preference, but hey, .Net is .Net, right?I've heard that moq has some trouble with VB. Is this true? Is so, what sorts of trouble? I would expect it to work fine given the language agnostic nature of .Net.
Should I look into using some other mocking framework for use with VB?
View 2 Replies
Sep 1, 2011
I have a unit test project and a project A that refers to the dll B. When make changes to the dll B and build my solution again I get an error meassage: could not load dll B or one of it's dependencies when i try to run the test project. The dll B does not exists in the references of the test project.
View 11 Replies
Sep 18, 2011
Doing some homework on unit testing and in all honestly i just don't get why i get this error.
i got a simple method that select all text when tab and testing if the actually textbox1 is selected. I just don't get why i'm getting a nullReferenceException at target.txtbox1_Enter(sender, e)
Private Sub txtbox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtbox1.enter
Dim txtBox As TextBox
[Code].....
View 1 Replies
Apr 1, 2011
I'm wanting to create a load of unit tests to make sure my stored procedures are working, but i'm failing (i'm new to tests in visual studio).Basically I want to do the following:
<testclass()>
Dim myglobalvariable as integer
<testmethod()>
[code]....
The problem is because the tests don't run sequentially, tests 2 and 3 fail because the global variable isn't set.
View 4 Replies
May 4, 2009
Can anyone point me towards a complete scenario using MSTest,vb.net, with or without mocks,MVP (supervising controller)
View 1 Replies
Jul 21, 2009
I am trying to unit test a controller action that uses the membership provider to update user details. I am using Moq which so far has been easy to use. The problem is I can't seem to get it to mock calls to methods that don't return anything.
[Code].....
View 4 Replies
Nov 19, 2010
What are some easy and simple unit testing frameworks to use with Visual Studio 2010 Express vb.net?
Are there any good tutorials geared towards this?
View 2 Replies
Jun 16, 2010
I am porting over some C++ assembly to VB that performs demodulation of various waveforms.I decided to go the unit test route instead of building a test app to get a feel for how testing is performed.The original demodulation code accepts an array that is the waveform along with some other arguments. How should one go about performing a test on something that has an array as an argument? Is it acceptable to generate fake data in a file and read it in at the beginning of the test?
On a side note - The original C++ code was written because we were performing math that we couldn't do in VB6 so we had to cross boundaries between C++ and VB6 and arrays were used. Is there a "better" way of handling large amounts of data in the .NET world that us VB6 programmers may not yet be privy to? Or if we aren't crossing that managed/un-managed boundary, should we be representing our data as objects instead?
View 2 Replies
Jun 24, 2009
I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I would like to implement some unit testing. I created a class in the app_code folder and added Imports NUnit.Framework etc... After writing a basic test, I get the "Can't execute tests in 'Web Site' application." error. I guess the Web Site project is not supported. Converting to a Web Application is not an option at this time. I have Visual Studio Test Edition, so I tried that route. I created a test project, wrote a couple tests in my test class etc... only to find out I cannot reference the classes in the app_code folder of the Web Site project.
View 2 Replies
Oct 5, 2011
Was wondering how you do this?As it's very annoying to click "ok" everytime a message box pops up.
View 2 Replies
May 20, 2010
I have been reading some articles on unit testing but I still have some questions.
- What should be tested if we want to test if an entity can be saved or not?
- Should we test each and every property of the entity?
- If I have a solution consisting or 3 projects, will the unit test go become the 4th project?
View 2 Replies
Feb 19, 2009
I'm running some unit tests for a large VB.Net application I help maintain and am running into problems with tests timing out. The test run is set up so that there's no timeout limit on the overall test run, but a limit of 2 minutes per individual test. However, a couple of the tests take a lot longer than this to run, so we tried adding the timeout attribute to the test's declaration, i.e
<TestMethod(), Timeout(15 * 60 * 1000)> Public Sub DoSomething()
for a 15 minute timeout. However, the 2 minute timeout set in the test run properties seems to be taking precedence, even though it says that the timeout attribute should override it.
View 1 Replies
Aug 10, 2010
Unit test method that has Public Read Only property, how do I set the public read only property?target.MyReadOnlyProperty = MyObject
View 1 Replies
May 13, 2010
In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?, I was asking about InternalsVisibleToAttribute.I have read the documentation on how to use it, and everything is fine and understood. However,I can't instantiate my class Groupe from my Testing project.I want to be able to instantiate my internal class in my wrapper assembly, from my testing assembly.
EDIT #1
Here's the compile-time error I get when I do try to instantiate my type:
Erreur 2 'Carra.Exemples.Blocs.ActiveDirectory.Groupe' n'est pas accessible dans ce contexte, car il est 'Private'. C:OpenProjectsExemplesSrcCarra.Exemples.Blocs.ActiveDirectoryCarra.Exemples.Blocs.ActiveDirectory.TestsGroupeTests.vb 9 18 Carra.Exemples.Blocs.ActiveDirectory.Tests
(This says that my type is not accessible in this context, because it is private.) But it's Friend (internal)
EDIT #2
Here's a piece of code as suggested for the Groupe class implementing the Public interface IGroupe:
#Region "Importations"
Imports System.DirectoryServices
Imports System.Runtime.CompilerServices[code]........
View 3 Replies
Jun 22, 2009
I've set up a test database to begin unit-testing an app that I've recently been added to. It is a 3-tier design (presentation layer, BOL and DAL) and this is my first time writing unit tests. I've decided to start at the BOL and I figure the best way is to swap out the ConnectionString (which has been passed along as a Shared String) with one that points to my new test database. However, I don't wish to change any production code. I simply wish to somehow redirect the app to the test database during unit tests.
View 4 Replies
Mar 11, 2010
We are looking to make a final decision on our Mocking framework. After trying several, I have fallen in love with Moq. I also love TypeMock - but because we are in the early stages of implementing TDD across the team, we do not want to make such a large investment quite yet. We are using VS 2008 now and are going to move to 2010 as soon as it is released.
So after doing much research I have decided on Moq because it's nearly as good as TypeMock and has super clean syntax, etc. Now here's the problem/question: we are mainly a VB.NET shop but are using C# for all of our CRM implementation code (plugsins, etc). It seems Moq only fully supports C# due to VB.NET lacking Lambda sub routines. Can anyone confirm that when VS2010 comes out Moq will work fully with VB.NET in its current version?
Is anyone here using Moq with VB.NET? w/ 2010? We need to make this decision asap, as we are under tight deadline and do not want to change frameworks again (went from NMock to TypeMock and now want to make final decision and move to Moq) or have 2 separate ones per language...
View 1 Replies
Feb 1, 2011
I'm wondering how to evaluate an expression using the assert object. The idea is to check if a string is longer then what is minimally acceptable. For example, Assert.AreEqual(stringName.length, >5). I know this method doesn't work but the concept is what I'm trying to get across. Is there a way to test this?
View 1 Replies
Feb 9, 2011
Consider the following method that stops a service:
Public Function StopService(ByVal serviceName As String, ByVal timeoutMilliseconds As Double) As Boolean
Try
Dim service As New ServiceController(serviceName)
Dim timeout As TimeSpan = TimeSpan.FromMilliseconds(timeoutMilliseconds)
[code]....
I agree that for domain model code that using the "traditional" unit testing approach makes the most sense as this would lead to a design that is easiest to maintain. However, for code that deals with the .net implementation of Windows API related stuff (file system, services, etc), is there really an advantage to going thru the extra work to get "traditionally" testable code?
It's hard for me to see the disadvantages of using Microsoft Moles for things such as ServiceController (or the File object). I really don't see any advantage of doing the traditional approach in this case.
View 2 Replies
Dec 30, 2009
I have a URL lets say . some time i need to send HTTP and some time i need to send it to HTTPS for that i created a enum:
Private _protocol As Protocol
Enum Protocol
HTTP
HTTPS
[CODE]...
Now when i get value back from protocoltype it returns me integer value as enum do so tell me how to get string from enum or other substitute.
Dim targetUri As String = setting.protocolType & "://www.mysite.com"
View 1 Replies
Jul 21, 2010
I have written one application which communicate with one data logger unit (temperature monitoring unit) and download records after some interval. Unit continuously send current temperature which I have to show on screen and after each one hour I have to download log (all records saved inside unit at max 1024) from unit.
Now problem is after downloading log, application get hang or what we called working in background and resume after some time. If I pause debugger in visual studio 2008 it show control at application start (sub main) with message as "application will resume here after completing execution of current function". There is nothing in output window. So how can i trace is there any events got spool or what actually application doing in background.
View 1 Replies
Apr 12, 2011
Does anyone have a nice sample of a unit convertor handling multiple unit types that I can integrate in my application? I have found this one, but it is only handling one type of unit. For example I want to convert weight as well as volume from and to imperial units.
View 8 Replies
Mar 25, 2011
I'm trying to declare an enumeration and one of the names I'd like to use for an item is not usable apparently. Where I am declaring 'STEP = 3', I get this error message in visual studio: "Statement cannot appear within an Enum body. End of statement expected." Is it possible to use STEP as an item name somehow? [Code]
View 4 Replies
Jan 2, 2012
RE - FilesystemRights Enum
This Code:
Dim FSRS As Type = GetType(FileSystemRights)
For Each fsr As String In [Enum].GetNames(FSRS)
TextBox1.AppendText(fsr.ToString & vbCrLf)
Next
View 3 Replies
May 26, 2010
Which is better, using a nullable enum or adding the value None=0 to your enum list?Using nullables requires more code, but I kind of like it since it forces me to think about the possibility. Otherwise I'm liable to forget about the None enum and fail to account for it being a special case.
View 11 Replies