Implementing NHibernate Unit Test To Generate Schema With .NET/MBUnit?

Jul 1, 2009

I'm trying to implement unit tests for my NHibernate data access layer. The first test, which I drew from an example I found on the web [URL] is just trying to recreate the database using my domain classes/mappings. I've been able to get this sample working in C# (Product table is created in database) but not when I implement it in VB.NET.I have two projects, Todd.Core (containing Product class and Product.hbm.xml mapping) and Todd.Core.Test (containing Test Fixture and NHibernate configuration). When I attempt to run this test using MBUnit GUI I get this message (line 10 is the call to the .Configure method):

Message: Could not compile the mapping document: Todd.Core.Product.hbm.xml

Type: NHibernate.MappingException
Source: NHibernate
TargetSite: Void LogAndThrow(System.Exception)
HelpLink: null

[code].....

View 1 Replies


ADVERTISEMENT

Tool That Will Auto-generate Unit Test Stubs?

Aug 13, 2009

I am writing a winforms application and eventually I would like to write unit test for this application from the DAL, and Biz Objects layers etc.

Does someone know of a FREE tool that can recieve the path to an assembly and then output unit test stubs with matching signatures for the assembly.

Any configurable options like "public interfaces only", "test framework choice", "language choice" would be a plus.

View 4 Replies

Write A Unit Test Assembly In C# To Test Against An Assembly Written In VB?

Sep 20, 2011

Probably a dumb question, but can you write a unit test project in one language to test against another project in a different language?I'd like to translate one of our VB assemblies into C#, but want to build unit tests to verify the results. I've tried to set a unit test project up to do this, but I can't seem to access the VB code within a unit test... I can't figure out if I'm just missing/doing something stupid, or it really isn't allowed.

View 2 Replies

Could Not Run Unit Test With Mock

Apr 18, 2012

I tried to make an unit test for this method which is pretty simple only add an object into the data base and if it works well returns true

[Code]...

View 1 Replies

Using Resources In A Unit Test?

Sep 10, 2009

I created some string resources in My.Resources. I want to use those resources in my unit tests.How do I expose these resources to my unit test project?I tried simply setting the Access Modifier to "Public" for the resources. This made it so that I can compile the code, but it is ignoring the culture setting.

Bo.My.Resources.Culture = New CultureInfo("en-GB", False)
LocaleTest(Bo.My.Resources.Yes, "Yea")

View 2 Replies

Using XML DataSource In Unit Test

Mar 3, 2010

I am writing a test unit (in MSTest) that consumes an XML file located in the testing project. I have this (solution name is BusinessLogic, project name is BusinessLogicTest):

Public TestContext As TestContext
<TestMethod()>
<DeploymentItem("BusinessLogic.BusinessLogicTestTestData.xml")>
<DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
"|DataDirectory|TestData.xml", "Row", DataAccessMethod.Sequential)> _
Public Sub ConvertIntToRoman_DataDrivenTest
[Code] .....

However, when I run the test I get an error: The unit test adapter failed to connect to the data source or to read the data. I belive it's something to do with my DeploymentItem and/or DataSource, however, I cannot find an example (in VB) that works anywhere.

View 2 Replies

Report Progress Of Unit Test?

Oct 5, 2010

Is there currently any possible way to report progress of my unit test? I have a test that could take up to a hour, and I don't want to sit there not knowing what % it is done with. I have tried writing with debug.print and trace.writeline, neither of which seem to work.

View 1 Replies

Unit Test And SQL Database Connection

Jun 3, 2009

I am having a problem with a unit test I have created. First time doing this so I am not sure why I am getting this error [code]Test method ETDS_Unit_Tests.LoginTest.ValidateUserNameTest threw exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).This is the same connection that my software is using, and the software runs fine, only the unit test is failing. What I am doing wrong? It Seems to fail one time for each datarow in the table.Also, I am using a Linq Query in the method that I being tested. I believe that this may be what is causing my error.

View 2 Replies

Unit Test Constructor That Uses My.Settings

Mar 12, 2009

I have a constructor that looks like this:

Public Sub New()
MyBase.New()
ws.Url = My.Settings.WebServiceURL
End Sub
(ws is private)

Is there any point in unit testing this?

The class did not previously have this constructor.

View 1 Replies

Unit Test To Have Global Access To Everything?

Mar 24, 2010

Usually when you add one (in Visual Basic), it pops up a message asking if you want to enable an option that lets the test access things like private methods etc.

However, I am editing a solution that does not have this enabled. I'd like to enable it so my unit tests will work, but I can't find the setting.

Can anyone tell me how to enable it after the project has been created?

View 1 Replies

C# - Unit Test Fail When Comparing Two Doubles?

Mar 30, 2011

I have the following code in vb.net that calculates the amount before tax was applied:

Public Shared Function CalculateRateBeforeTax(ByVal rate As Decimal, ByVal tax As Decimal) As Decimal
Dim base As Decimal = rate / (1 + (tax / 100.0))
Return Math.Round(base,2)[code]....

I put the above scenarios into some unit tests using c# and using the nunit testing framework. The first scenario passes, but the other fails and I am not sure how I can get it to pass. Here is are my tests:

[TestFixture]
class TaxTests
{[code].....

As I said before, the first test passes, but the results of the other tests are:

Second Test expected 305.1600000000000003d But was: 305.1643192488263d

Third Test expected 95.54999999999997 But was: 95.55555555555555557d

View 4 Replies

Create A Unit Test For The The Page_Load Function In ASP.net?

Apr 11, 2011

How can create a unit test for the the Page_Load function in ASP.net?

I am using build in Visual Studio Unit test frame work. I want to create a unit test that check the Elements of the web page and their values.

I know about selenium and its abilities in unit testing.

This is the web Page to test WebPageControl.ascx.vb:

Public Class WebPageControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

[Code].....

View 3 Replies

How To Create Unit Test For ActualHeight In Silverlight 4

Apr 22, 2010

How can I write a unit test to test the actualWidth property to a userControl in Silverligh 4? I hoped that this method would pass, but it fails. I am using the Silverlight ToolKit april 2010, and VS 2010.

<TestMethod()> _
Public Sub TestAcrtualWidth()
Me.MyUserControl.Width = 100
Me.MyUserControl.UpdateLayout()
Assert.IsTrue(Me.MyUserControl.ActualWidth > 0)
End Sub

View 1 Replies

Unit Test KeyNotFoundException Without Assigning Dictionary Value?

Mar 20, 2012

I wish to run a unit test on a particular dictionary in my code, trying to get a value I don't expect to be in the database (in this case, key=1).

I have written the following code:
Try
Dim s As String = myDict(1)

[code].....

View 3 Replies

.net - Unit Test Fails, Tested Code Works?

Aug 14, 2009

I have a simple unit test which tests that a validation function picks up a specific validation issue. The validation item returns a simple object with Item & Message properties. I've written a unit test for this function but this always fails even though I know the function works as expected.

<TestMethod()> Public Sub ContractNote_ValidateForManualInputTest_TradeOrderValueComparison()
'Can't get this test to work even though validation works!
Dim CN As ContractNote = New ContractNote
Dim Trade As New TradeOrder

[code].....

I've implemented IComparable on ValidationItem (I have a separate unit test which confirms this works). Am I Using CollectionAssert correctly?

View 1 Replies

.net - Using Lambda In Unit Test In 2008 With Rhino.Mocks?

May 12, 2009

I am trying to create a unit test similar to how I would have done one in C# but am struggling with the lambdas in vb. Bascially I am trying to mock a class and then create a stub and return. In C# I would have done something like;

MockedPersonRepository
.Stub(x => x.Find(id))
.Return(person)

[code].....

View 2 Replies

Getting An Error While Trying To 'Unit Test' Connection-method To Sql Database

Dec 7, 2010

I just bought the MCTS Self-Paced Training Kit (Exam 70-561): Microsoft.NET Framework 3.5 - ADO.NET Application Development, and am trying to do the Lab Exercises now. Allready at the first exercise (point 8), where I am supposed to make an "UNIT TEST",[code]

View 5 Replies

Unit Test Inconsistent Pass Or Fail Result?

May 16, 2011

One of my unit tests seems to randomly pass or fail when I run it. The only thing that makes sense to me for why this is happening is if the data in the database is getting into a different state each time the test is ran, but I use transactions to rollback the database in each test - unless it's not working right. Here's my base unit test class and the unit test class that's having the problem. Can you see anything I might be missing or what else I should look for?

This happens with TestDriven.Net and the Visual Studio Unit Test Framework.

[Code]...

View 3 Replies

Unit Test Private Functions From A Separate Project?

Aug 18, 2011

As I develop code, I often want to unit test some of the building blocks of a class even if they are normally private. If my unit tests are inside the project, I can use "Friend" to accomplish this and still keep the functions private for normal use. But I would rather move my NUnit tests into their own separate project(s). How do I achieve the effe vb.net 2005?

View 11 Replies

Why Does WatiN Timeout When It Is Indirectly Called By A Unit Test

Aug 12, 2009

I'm using WatiN to run IE inside a VB .NET function:

[Code]...

View 1 Replies

Write A Unit Test That Verifies A Subroutine Is Called?

Dec 20, 2010

Public Class Class1[code]...

Granted this example is pretty weak, but how could I write a test method that to prove that CallThis() gets called everytime that the input parameter s = "S"?

View 5 Replies

Unit Test Private Functions From A Separate Project In Program?

Mar 15, 2009

As I develop code, I often want to unit test some of the building blocks of a class even if they are normally private. If my unit tests are inside the project, I can use "Friend" to accomplish this and still keep the functions private for normal use. But I would rather move my NUnit tests into their own separate project(s).

View 3 Replies

Asp.net - Swapping A Connection String To Access A Test Database For Unit Testing?

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

Use Reflection To Unit-test An Internal Class Within An Assembly When The InternalsVisibleToAttribute Is Not An Option?

Aug 26, 2010

I have a solution with two projects within:

Company.Project.vbproj
Company.Project.Tests.vbproj

Within the Company.Project.vbproj assembly, I have a class FriendClass.vb which scope is Friend (internal in C#).Now I wish to test this FriendClass.vb from within the Company.Project.Tests.vbproj assembly. I know about the InternalsVisibleToAttribute, but that is not an option in Visual Basic .NET 2.0, as it is only available with C#, in .NET 2.0 (see here).I would like to create myself a proxy class using this internal FriendClass from within my testing assembly, so that I could instantiate it and do the testings accordingly.

View 1 Replies

.net - Out Of Process COM Server Works Fine In The Unit Test Harness But Not In The Real Service?

Jun 1, 2011

We have a WCF service hosted in IIS that currently calls a VB6 DLL to do part of its job. This works fine, but we can't deploy the service to a 64-bit target environment without configuring IIS to run it in a 32-bit worker process.I am currently investigating ways around that restriction. Porting the VB6 DLL to .NET is not possible for various reasons, so I created an ActiveX EXE wrapper around the DLL in VB6, so that the service can run in 64-bit and the VB6 parts in 32-bit.

When I tested the service I got this error:

Type: System.UnauthorizedAccessException
Message: Retrieving the COM class factory for component with CLSID {9AE7303B-D159-43F6-B1A5-52D297581820} failed due to the following error: 80070005.

After some Googling I found that this is due to either:

Calling an MS Office component
DCOM permissions not being configured
NTFS file permissions not allowing read/exec access to the IIS worker process identity (ASPNET in my environment)

Of these:

Definitely not applicable Also not applicable; I am not hosting the EXE in DCOM or COM+, just a simple COM out-of-process activation
This looks likely; however, I checked the permissions, and NTFS reports that the Users group (which ASPNET is a member of) does indeed have read/exec access to the file I tried calling the EXE from a unit test fixture, which is executed in my admin-level account rather than the IIS worker process account, and it worked fine, so the error is definitely something to do with permissions. I'm not sure what to do next.

UPDATE:The IIS virtual directory is configured for Anonymous+Windows access; the WCF service uses only Anonymous authentication, the Windows authentication is for the VS debugger. Task Manager reports that the aspnet_wp.exe process is definitely running in the ASPNET account.I explicitly granted Read and Execute access to the ASPNET and IUSR_<machine> accounts on all the COM exes and dlls involved. This made no difference.

I explicitly granted Local Launch and Local Activation access to the ASPNET and IUSR_<machine> accounts on the relevant interfaces in the DCOM configuration. This made no difference either.Keep trying to get this working somehow.Go the whole hog and host the EXE in COM+.Give up. Tell users that the WCF service must be configured to run in a 32-bit app pool on 64-bit Windows.

View 1 Replies

.net - NHIbernate NHibernate Attempts To Execute A Database Update During CreateQuery Execution?

Mar 10, 2010

Basically, I wish to fetch a filtered set of objects from the database (Oracle 9.2) based on the id property of the object PsalertsEvent. The code being executed is:

Public Overloads Function GetAll(ByVal laterThan As Long, ByVal filteredPsalertsEvents As IList) As IList Implements IPsalertsEventRepo.GetAll
'Get all psalerts events with an ID greater then the specified laterThan parameter
filteredPsalertsEvents = MyBase.NHibernateSession.CreateQuery("from PsalertsEvent p where p.id > " & laterThan).List

[Code]...

View 2 Replies

MS Entity Framework VS NHibernate And Its Derived Contribs (FluentNHibernate, Linq For NHibernate)?

Feb 4, 2010

I just read this article about the Entity Framework 4 (actually version 2).Entity Framework seems to offer a huge improvement over its first release. Thus, I have never ever used EF in any project, since I think EF is not mature enough in comparison to NHibernate.NHibernate and its current contributions of FluentNHibernate and Linq for NHibernate by Ayende RahienMy feeling is that Microsoft is solely trying to gain terrain it has lost in favor of NHibernate when the 2nd version of NHibernate came out.Nevertheless, my concerns are the followings (not in particular order):Will EF4 tend to be less XML-verbose?Will EF4 be compatible with other underlying datastore than just SQL Server?What are the greatest benefits of going with EF4 instead of FluentNHibernate or NHibernate itself.

NHibernate is a great tool, I guess everyone agrees. Due to its predecessor Hibernate, we may easily find documentions and tutorials and sample applications to get acquainted with it. This is not the case for FluentNHibernate. Particularly as per the project I'm working on right now which demands that I investigate further about NHibernate and its options (FluentNHibernate for instance) in order to document the rules of usage and the best practices of NHibernat and FluentNHibernate technology. Thus, being handcuffed with VB.NET, being a C-Style developer, I can't find some syntax equivalencies in VB.NET for the examples provided, though I made I way so far

View 3 Replies

VS 2008 .NET For NHibernate And Fluent NHibernate?

Oct 26, 2010

I would like to ask if you can use VB.NET for NHibernate and Fluent Nhibernate?I have searched the web, but I can't seem to get a detailed or explicit statement that tells that one can use VB.NET for NHibernate and with Fluent.

Many of the samples in the NHibernate site are made in C#. That's why I was wondering if I can't use VB.NET when using NHibernate.

View 2 Replies

Application Which Communicate With One Data Logger Unit (temperature Monitoring Unit)

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

VS 2008 Unit Converter Handling Multiple Unit Types

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







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