C# - Cannot Assert Against Object?
Jun 25, 2012
This is probably a very simple Object Oriented Programming question. What I am trying to do is take 2 empty objects, use a query to pull data from a database, populate the empty objects with the data returned from the query, and then assert against them. See the code below:
[Code]...
I wrote a very similar test method in VB following the same patterns and the VB code executed just fine.However whilst transitioning from VB to C#, I run into issues such as these. The compiler says "Use of unassigned variable" at the assert. However, I thought I was assigning to a value within the code block above. What am I doing wrong?
View 2 Replies
ADVERTISEMENT
Jun 23, 2011
My understanding of assert.fail was that if the line is executed, the test will fail.owever, I have found an instance where the assert.fail is executed, but the test passes.If the Assert.Fail statement is within a try block, the test will ALWAYS pass, even if the code execution executes the assert.fail. For example, the following test will always pass, even if the sub fails to throw an exception.
View 2 Replies
Feb 18, 2011
I'd like to add a message to be displayed in Visual Studio 2010 test results.I can post a message out if the test fails, but not true. Is there anyway to do this? For example:
dim quoteNumber as string = Sales.CreateQuote(foo)
assert.IsTrue(quoteNumber <> "")
'I would like to make this something like this:
assert.isTrue(quoteNumber <> "", falsepart, "Quote number " & quoteNumber & " created")
View 3 Replies
Jan 20, 2009
I am doing regression testing using NUnit, WatiN and VB.net. What I am doing is opening an IE page, selecting some data, making a registration and then on view registration page testing the registration by assertion. Any good way to use try and catch on every assert. i am using it because if some assert fails it will stop executing the rest of the statement and quits without running rest of the tests. Now I have put try and catch on every assert and writing the fail message in log file.
For instance If I am checking for some airline reservation booking. After creating a booking, On view Booking Summary Page I am testing weather it is displaying cancel booking button or not. For this I am using the following code:
Try Assert.IsTrue(_internetExplorer.Button(Find.ById(New Regex("CBooking"))).Exists)
Catch ex As Exception d_logger.LogResultTextFile("Cancel Button does not Exist", True, False) End Try
I am checking this by running this in a loop for no of bookings created. I want to keep running the test even if in one booking it wont finds the button but keep checking for other bookings.
View 1 Replies
Sep 20, 2011
I'm surprised to get a compile error in release mode with the following code.I have a DEBUG only function declared
#If DEBUG Then
Private Function DEBUG_Check() As Boolean
'Do some checks[code]....
I get a compilation error "DEBUG_Check is not declared"I thought calls to Debug.Assert were completely removed from Release compile?
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
Jul 10, 2010
I am somewhat new to object oriented programming and am attempting to flatten a Linq object hierarchy by using a shim class.how to initalize a derived class with property values from a base class?I have two objects, a base object with about 100 properties, and a derived object which inherits from the base object and adds a few additional properties beyond those of the base object. My simple constructor creates the derived object, but I am looking for a way to initialize the derived object properties with values from the base object.Right now I am using reflection to iterate over the properties individually and I suspect there may be a better way. The following example shows my shim class constructor for the derived class, and two properties:
newProperty1 - a new string property of the derived class
flattenedProperty2 - a new string property of the derived class, copied from a 2nd-level object of the base class
Code example:
Public Class derivedObj
Inherits baseObj
Private _newProperty1 As String[code].......
Is this the correct constructor approach to flatten the object hierarchy using a shim class? My second question relates to initialization of properties in the derived class. The constructor above creates the derived object, but what is the best way to initialize the derived object properties with values from the base object? The following code uses reflection to iterate over the properties individually, but I suspect there may be a better way.
Code example:
' property names are in the string array fieldNames
'baseObjQuery is an ienumerable of baseObj
'derivedObjList is a list of derivedObj[code].....
Is there a simple way to initialize values for the properties in the derived object based upon the values of the common properties in the base object?
View 7 Replies
Jul 29, 2011
I am getting following error whenever I want to use IIf function inside entity framework query.
LINQ to Entities does not recognize the method 'System.Object IIf(Boolean, System.Object, System.Object)' method, and this method cannot be translated into a store expression.
View 1 Replies
Apr 16, 2010
What do I need to convert?
Dim CEESearchByAppNo = From CEEsearch In dbCEE.tblScanneds _
Where CEEsearch.AppNo = iAppNo
[code].....
View 5 Replies
May 8, 2009
How do I calculate the direction an object is facing in degrees, if object A is at x1, y1 and facing object B which is at x2, y2?
View 2 Replies
Dec 31, 2009
Occasionally I encountered this exception message while trying to download file from a server using System.Net.FtpWebRequest and System.Net.FtpWebResponse Object.
Download a file.ftpRequest_DL.Method = WebRequestMethods.Ftp.DownloadFile get the response object
Dim ftpResponse_DL As FtpWebResponse = CType(ftpRequest_DL.GetResponse, FtpWebResponse)
[Code]...
View 4 Replies
Oct 18, 2010
If I declare my object at the beggining of my page class, and instantiate it in a dropdownlist selected_index change event. Shouldn't this object be available thru out the entire page and also persist thru a postback? I lose the object in my selected date change event in my calendar.
[Code]...
View 3 Replies
Mar 1, 2012
I have an ssis package that takes a flat file and dumps it to SQL. During that process, 150 columns need to have '-' and '.' removed from them. I have done this using a Script Transformation.
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim column As IDTSInputColumn90
Dim rowType As Type = Row.GetType()
[code]....
Edit I've discovered that this line is the problem
Dim strCol As String = columnValue.GetValue(Row, Nothing).ToString()
View 1 Replies
Oct 16, 2011
I am trying to start the process with the following parameters When I try to start it though I get an System.nullreferenceexception: Object reference not set to an instance of an object
Dim exepath As String = Application.StartupPath + "inffmpeg.exe"
Dim sr As StreamReader
Dim cmd As String = " -i """ + input + """ -ar 22050 -y """ + output + """"
Dim ffmpegOutput As String
[code]....
View 16 Replies
Jan 12, 2011
In the Session_Start of the Global.asax i have
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Session("login") = False
[code]....
Why i am getting error the error Object reference not set to an instance of an object. at line
If Current.Session("login") Is Nothing Then
while checking for the login state as follows?
If GetLogin = False Then
'Do something
End if
I mean i have already created the instance on the Session_Start... Haven't i?
View 1 Replies
Oct 26, 2009
I have an object that is defined as a global variable based on custom class. Within that class I have an event that gets fired a certain intervals. These events are fired on the same thread as where the object is declared. How do I create a global object, but have the events within that object fire on a separate thread?
View 2 Replies
Jan 12, 2010
i am using VB.net 2003 and i am trying to get the number of rows of a dataset from form1 into form2 in order to use it for something else and i am getting the error"System.NullReferenceException occured...Additional information: object reference not set to an instance of an object"...my code is like this:in form1:Public x as integer= me.dataset.table.rows.count here it gives me the error
in form2:
dim frm as new form1
msgbox(frm.x)
View 1 Replies
Jan 5, 2010
I am getting this error when I try to print my report. Here is my print code.
Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
Dim Print_Dialog As New PrintDialog
[code].....
Here is my error: System.NullReference Exception: Object reference not set to an instance of an object.
View 1 Replies
Jan 29, 2012
I'm trying to set the format of a column in a datagridview.When I put the format statement in the on load event for the form, it has no effect. When I put it in the cellformatting event I get the "Object reference not set to an instance of an object" error. I checked the column name. What I am doing wrong?
This is the code:Private Sub MeetingTblDataGridView_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles MeetingTblDataGridView.CellFormatting
Me.MeetingTblDataGridView.Columns("Starttime").DefaultCellStyle.Format = "HH:mm:ss"
End Sub What I'm trying to do is get rid of the date part of a Date/Time field (stored in an Access database) in a datagridview column.
dp.SyntaxHighlighter.ClipboardSwf = '/dp.SyntaxHighlighter/Scripts/clipboard.swf'
dp.SyntaxHighlighter.HighlightAll('09dde30f062e451a854266e66205b1cf')
View 10 Replies
Jun 7, 2012
I know how to handle a single objects property changed event very easily. I want to handle a objects property changed event that is part of another object.
Given Object:
[ObjectY = Y]
+ Public WithEvents X As ObjectX
I would like to do something like:
Private Sub XPropertyChanged() Handles Y.X.PropertyChanged
Right now I need to create a object that equals the object inside that object and then handle this variable pointers property changed, but that is just annoying.
View 1 Replies
Aug 14, 2010
with datagridview1
while looping through all the cells
i am trying to allot a cell value to another cell value basing on some conditions
& finally delete one column.my code is as fallows
Dim i, x As Integer
i = 0
x = Me.DataGridView1.Rows.Count[code]....
error i am getting is : Object reference not set to an instance of an object.it is extremely surprising for me the same code has worked nice for me but why & how the same line of code is generating this error.
View 10 Replies
Jan 12, 2011
I am trying to write an VBA application in Excel 2010 using "Microsoft Soap Toolkit 3.0" on 64 bit Windows 7 to consume an web service. But i got an error while initializing an object of SoapClient30.
Error message is :: Runtime error '429' :ActiveX component can't create object.
View 2 Replies
Mar 21, 2012
how I could have an object bounce back when it collides with an rectangle shape. There are multiple rectangle shapes and I don't want to do it all seperately for each one.
View 1 Replies
May 8, 2012
I tryed searching for an user in active directory using the code below but it gives me the error in the title of this post above:
AD = New DirectoryEntry("LDAP://OU=SchoolOUhere,OU=Staff,DC=garrard,DC=ketsds,DC=net", "", "", AuthenticationTypes.Secure)
AD2 = New DirectoryEntry("LDAP://OU=_Groups,OU=Staff,DC=garrard,DC=ketsds,DC=net", "", "", AuthenticationTypes.Secure)
[Code]...
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to[URL]...
View 4 Replies
Aug 6, 2010
Here is the structure that I have:
Friend Class StandardFormatFile
Friend fileType As String
Friend numberOfSeries As Integer
[code].....
View 3 Replies
Mar 14, 2010
The issue is when I try to add a new item to the ArrayList with the following code, it gives me an error:
vb Private Sub btnLabelAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLabelAdd.Click
Dim result As String = InputBox("New Filter Label:", "Label List")
[CODE]................
Object reference not set to an instance of an object.
I'm not really sure what I'm supposed to be doing with this. It's a new setting I just added and it's empty, so I'm not sure if that has anything to do with it or not. Anyone know what's going on and what needs to be done to get it to accept a value and not want to be "initialized"?
View 9 Replies
Oct 23, 2009
I have recently gotten my hands on a free, open-source IMAP connection API.So far, I have been successful in creating a connection to one of my accounts.Where I'm getting stuck is retrieving folders and/or emails from those folders.Does there happen to be anyone here that is familiar with this API, or even Gmail (particularly the folder structure for IMAP)?
If not, here is a link to the DLL that is listed on sourceforge and the company's website that created it (if you feel like testing):
Koolwired
Sourceforge - Koolwired API
I have created a test account so feel free to use the code below without worrying about username/password issues; I'll just delete it when I'm done with it.Here is the code I have made so far for making a connection:
Dim gSession As New Koolwired.Imap.ImapConnect("imap.gmail.com", 993, True)
Dim gAuthenticate As New Koolwired.Imap.ImapAuthenticate(gSession, "imap_test@serysoft.com", "imap_test")
Try
[code]....
When I run that code, I get an error that states:System.NullReferenceException: Object reference not sent to an instance of an object. (The bold line in the above code).
Now, I'm not sure exactly what that means. Does that mean it tried to access the server and "INBOX" doesn't exist so it gets returned a NULL value? Or is it possibly the coding itself?Maybe the Gmail folder system is weird due to the fact they use labels (even though from what I have read online, the labels act as the folders in the IMAP system).
View 11 Replies
May 3, 2011
I was create Access database with Access 2003. I create VB project with Visual Studio 2005 Standard With connection wizzard I create coonect with this Access database, select all tablesI see this database inside Data sources and inside Server explorer Test connection is OK When I drag and drop table from Data sources, Wizzard don't create DataGridView, DataSourceBinding etc .. and I see popup window with mesage: Object reference not set to an instance of an object and then "game over"
View 2 Replies
Apr 18, 2010
I got the following code from the demo code samples and just changed the textbox names. But it throws an error:
Private Sub Fill_TextBox()
Dim Num As Integer
Dim DSet As DataSet
[code]....
The error is:
System.NullReferenceException:Object reference not set to an instance of an object.
View 1 Replies
Mar 4, 2010
Here is the code for the button click event;
Protected Sub CompetenciesButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CompetenciesButton.Click
Dim con As String = WebConfigurationManager.ConnectionStrings("foo").ToString()
[code].....
View 1 Replies