Basic/Simple testing questionBasic/Simple testing question
Old forum URL: forums.lhotka.net/forums/t/3651.aspx
RichM posted on Friday, October 05, 2007
We're just getting started with CSLA.NET after spending the last 8 years developing with our version of Lhotka's VB6 COM/MTS framework.
Having been used to doing quick unit testing via the immediate window in VB6, I tried this in VS2005 using some classes we'd written and tested with a simple UI. However, I've been unsuccessful creating a new instance of a class that inherits BusinessBase. I can create an emply class, let's say Class1, and do the following in the immediate window:
oo = new Class1
However, trying the same with a class that inherits BusinessBase does not work. Here's a simple, sample class:
<Serializable()> _
Public Class SomeClass
Inherits BusinessBase(Of SomeClass)
Private mcProperty As String
Public Property SomeProperty() As String
<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
Get
Return mcProperty
End Get
<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
Set(ByVal value As String)
mcProperty = value
End Set
End Property
Public Shared Function NewClass() As SomeClass
Return New SomeClass
End Function
Protected Overrides Function GetIdValue() As Object
Return 1 ' Don't care - just testing
End Function
End Class
Trying to do the following in the immediate window:
oo = SomeClass.NewClass
results in the error "Unable to evaluate expression."
For a more complex class that works when accessed via a Windows Form project, we get an error "SomeClass" is an unsupported type"
Is there some trick or environment setting to make this work?
skagen00 replied on Friday, October 05, 2007
I work in C# and rarely in the immediate window but don't you need to specify the "()" for the function call?
i.e. oo = SomeClass.NewClass()?
RichM replied on Friday, October 05, 2007
skagen00: I work in C# and rarely in the immediate window but don't you need to specify the "()" for the function call?
i.e. oo = SomeClass.NewClass()?
For a second I thought I was being real stupid.. Anyway - same error with or without the (). I had also tried a different factory method in another class similar to what Joe posted:
oo = SomeClass.GetClass(123)
with the same results.
JoeFallon1 replied on Friday, October 05, 2007
FWIW,
I was using a Web Project - not Winforms.
Joe
JoeFallon1 replied on Friday, October 05, 2007
I set a breakpoint in my code (happened to be in a BO) and then opened the Immediate window and requested a completely different BO. I set a breakpoint on the factory method and it worked. The code stopped there and I was able to step through the Data Portal and retrieve the BO.
oo = Acct.NewAcct("11602")
?oo.Acctcode
"11602" {String}
String: "11602"
Joe
Copyright (c) Marimer LLC