Can Write A Unit Test For CRUD Using In Memory Database With Fluent Nhibernate

Jul 6, 2010

How can I write a unit test for CRUD using in memory database with fluent nhibernate

View 2 Replies


Similar Messages:

How To Test Generate Tables With Fluent Nhibernate (schemaexport)

Nov 17, 2010

this is my very very first project with fluent hibernate.i've had small experience in hibernate and nhibernate:

This context is completely new to me since this is a web app project.

So i have my webapp project with most of the fluent nhibernate found on the net.

so i have This entities:

[code]....

View 1 Replies

Unit Testing - NullReferenceExpection In A Integration Test Project For A Nhibernate Solution?

Nov 19, 2010

i have a .NET 3.5 solution with an asp.net(web site) project with fluentnhibernate and it's test project(class library project).i've referenced the asp.net project in the test project and with all fluentnhibernate/nhibenate dlls.

What i fail to comprehend is that, on a run of a webform (hit from browser) let's say Test.aspx, building of schema is successfull and i could see the tables in my database.

here is the method i call on Test.aspx.cs

[code]....

So from my comment the NullReferenceException happens when accessing the connectionstring. I don't have the explanation on why that happens.

View 2 Replies

MVC :: Write Unit Test For Method With Parameter?

Oct 26, 2010

I'm trying to build my first MVC site and also write unit test for the first time. I can't figure how to write unit test for methods that take parameters. How do I write a test method for this controller action?

[Code]....

View 2 Replies

How To Create A Unit Test That Updates A Record Into Database

May 13, 2010

How do I create a unit test that updates a record into database in asp.net

View 1 Replies

ManyToManyMapping With Fluent Nhibernate?

Feb 16, 2011

I have a table USERS and GROUPS table.

I want to add another table UserGroups.

How can I map these tables.

View 1 Replies

ADO.NET :: How To Use Fluent Nhibernate - Finding Tutorials

Nov 9, 2010

, I want to use fluent hibernate with asp.net but couldn't find any website or tutorial for that , they're all to configure it with asp.net mvc , anyone knows any?

View 3 Replies

C# - Fluent NHibernate - Collections Not Filtering?

Aug 27, 2010

I have a session criteria statement (Fluent NHibernate) that does not seem to filter the child collection even though I have Expressions/Restrictions defined.

ICriteria criteria = session.CreateCriteria(typeof(MyClass));
criteria.CreateAlias("MyCollection", "MC");
criteria.Add(Restriction.Eq("MC.Property", value));
IList<MyClass> list = criteria.List<MyClass>();

This returns all the objects of type MyClass that have MyCollection.Property = value, however MyCollection is not filtered to MyCollection.Property = value

It seems like only the Root objects get filtered.

View 2 Replies

C# - Fluent Nhibernate No Persistor For Class Name?

Sep 9, 2010

I am getting this error even though all my mappings are pretty simple and correct. I get this error only on select classes.

View 1 Replies

Fluent NHibernate Data Caching From A Table

Feb 16, 2011

We are developing a multi-language web application with ASP.NET MVC 2 and Fluent NHibernate.Our platform will be multi-language. But just static text will be multi-language. Groups pages depends on community content whatever they use. Like Facebook.We decide to keep all language string in database. And load language when application starts.

View 1 Replies

Fluent NHibernate Cascade - Trying To Insert NULL ID?

Mar 8, 2011

I have the following models & mappings (code snippets further below).

One Competition has to have multiple CompetitionAnswers associated with it (multiple choice) from the outset.

At present, using the Fluent NHibernate mappings shown below, when I create a brand new Competition object, populate the properties, then create 3 brand new CompetitionAnswer objects and add them to the CompetitionAnswers property (property on Competition), I would expect to call Save on the session which would INSERT the 1 Competition row and 3 CompetitionAnswer rows to the DB.

However, as soon as I try to call Save on the session, it complains that CompetitionId is null and it can't insert a null into the CompetitionAnswers table for that field - which is right, it shouldn't, however, I assumed that the NHibernate would first create the Competition, then use the newly generated IDENTITY value (CompetitionId) in the CompetitionAnswers table?

[code]....

View 3 Replies

C# - (Fluent) NHibernate Security Exception - ReflectionPermission

Apr 11, 2010

I've upgraded an ASP.Net Web application to the latest build of Fluent NHibernate (1.0.0.636) and the newest version of NHibernate (v2.1.2.4000). I've checked a couple of times that the application is running in Full trust. But I keep getting the following error:

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +54
System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +269
System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +81
NHibernate.Bytecode.Lightweight.ReflectionOptimizer.CreateDynamicMethod(Type returnType, Type[] argumentTypes) +165
NHibernate.Bytecode.Lightweight.ReflectionOptimizer.GenerateGetPropertyValuesMethod(IGetter[] getters) +383
NHibernate.Bytecode.Lightweight.ReflectionOptimizer..ctor(Type mappedType, IGetter[] getters, ISetter[] setters) +108
NHibernate.Bytecode.Lightweight.BytecodeProviderImpl.GetReflectionOptimizer(Type mappedClass, IGetter[] getters, ISetter[] setters) +52
NHibernate.Tuple.Component.PocoComponentTuplizer..ctor(Component component) +231
NHibernate.Tuple.Component.ComponentEntityModeToTuplizerMapping..ctor(Component component) +420
NHibernate.Tuple.Component.ComponentMetamodel..ctor(Component component) +402
NHibernate.Mapping.Component.BuildType() +38
NHibernate.Mapping.Component.get_Type() +32
NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping) +39
NHibernate.Mapping.RootClass.Validate(IMapping mapping) +61
NHibernate.Cfg.Configuration.ValidateEntities() +220
NHibernate.Cfg.Configuration.Validate() +16
NHibernate.Cfg.Configuration.BuildSessionFactory() +39
FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:BuildsFluentNHsrcFluentNHibernateCfgFluentConfiguration.cs:93

Anyone had a similar error? I've seach the web / stackoverflow / NHibernate forums but only found people who had a problem when running in medium trust mode, not full trust. I've been developing for several months on this application on this machine with previous versions of Fluent NHibernate and NHibernate.

The machine I'm running this on is 64-bit, you never know that this is relevant.

View 1 Replies

Fluent NHibernate, Dynamically Change Table Of Mapping?

Feb 18, 2010

with fluent nhibernate, is there a way to dynamically switch the table of a mapping at runtime?

public class XYClassMap : ClassMap<XY>
{
public XYClassMap( )
{
Table("XYTable");
Id(d => d.Id).GeneratedBy.Identity();
Map(d => d.Value);
[code]...

View 2 Replies

Using MVC 2, StructureMap, Fluent NHibernate, And PostgreSQL - Finding Tutorials

Aug 8, 2010

I am using the above combo in a new web app Im doing just to try to learn to build new stuff to expand my knowledge. Im hoping to go live if I do a good job.. Im kind of new at MVC and the other products so I was trying to find a link to a good tutorial that set all of these up together.

View 1 Replies

C# - Update Parent Table From Child In Fluent Nhibernate?

Jul 13, 2010

I'm trying to update the data in the parent table that is referenced in the child table from the child's view in Asp.net.

I mapped the tables using Fluent Nhibernate.

In the child table, the mapping looks like this:

[code]....

View 1 Replies

C# - Fluent NHibernate Many-to-many Mapping With Auto-generated Pk Instead Of Composite Key?

Feb 2, 2010

I'm working on a RoleProvider in .NET, using Fluent NHibernate to map tables in an Oracle 9.2 database.

The problem is that the many-to-many table connecting users and roles uses a primary key generated from a sequence, as opposed to a composite key. I can't really change this, because I'm writing it to be implemented in a larger existing system.

Here is my UserMap:

public UserMap()
{
this.Table("USR");[code].....

Yet, this is giving me the error:

Type 'FluentNHibernate.Cfg.FluentConfigurationException' in assembly 'FluentNHibernate, Version=1.0.0.593, Culture=neutral, PublicKeyToken=8aa435e3cb308880' is not marked as serializable.

Is there a simple fix to allow this HasMayToMany to use my PersistentObjectMap extension? I'm thinking I may have to add a convention for this many-to-many relationship, but I don't know where to start with that, since I've just started using NHibernate and Fluent NHibernate only recently.

EDIT: I think I've found a possible solution here: http://marekblotny.blogspot.com/2009/02/fluent-nhbernate-and-collections.html

I'll try the above method of creating an entity and a class map for the linking table and post my findings.

EDIT 2: I created a linking entity as mentioned in the above blog post and downloaded the newest binaries (1.0.0.623).
This helped me discover that the issue was with setting lazy load and trying to add roles to the user object in a completely new session.

I modified the code to move OpenSession to the BeginRequest of an HttpModule as described here. After doing this, I changed my data access code from wrapping the open session in a using statement, which closes the session when it is finished, to getting the current session and wrapping only the transaction in a using statement.

This seems to have resolved the bulk of my issue, but I am now getting an error that says "Could not insert collection" into the USR_ROLE table. And I'm wondering if the above code should work with a UserRoleMap described as:

public UserRoleMap()
{
this.Table("USR_ROLE"); [code]....

Hibernate's documentation for many-to-many relationship suggests creating an object to maintain a one-to-many/many-to-one, as in an ERD. I'm sure this would be much easier with conventional naming standards, but I have to stick with certain abbreviations and odd (and not always properly-implemented) conventions.

View 1 Replies

Fluent Nhibernate Exception Error In System.Xml.Schema.XmlSchemaValidationException / How To Fix It

Jan 29, 2010

am trying to implement fluent nhibernate in MVC project...there were no build errors... but when i run the project i get this exception

System.Xml.Schema.XmlSchemaValidationException: The element 'class' in namespace 'urn:nhibernate-mapping-2.2' has incomplete content. List of possible elements expected: 'meta, subselect, cache, synchronize, comment, tuplizer, id, composite-id' in namespace 'urn:nhibernate-mapping-2.2'.

have no idea what am doing wrong here... the following is the code for opening session factory...

[code]....

View 3 Replies

C# - How To Configure Fluent NHibernate To Output Queries To Trace Or Debug Instead Of Console

Jan 25, 2010

How to configure Fluent NHibernate to output queries to Trace or Debug instead of Console?

I'm using MsSqlConfiguration.MsSql2008.ShowSql() but it has no parameters and I can't find anything on Google.

View 3 Replies

Unit Testing Error - The Unit Test Adapter Failed To Connect To The Data Source Or To Read The Data

May 6, 2010

I'm using VSTS 2K8 and I've set up a Unit Test Project. In it, I have a test class with a method that does a simple assertion. I'm using an Excel 2007 spreadsheet as my data source.

My test method looks like this:

[Code]....


As indicated in the method decoration attributes, my Excel spreadsheet is on my local C:/ Drive. In it, the sheet where all of my data is located is named "Sheet1".I've copied the Excel spreadsheet into my project and I've set its Build Action = "Content" and I've set its Copy to Output Directory = "Copy if Newer".

When trying to run this simple unit test, I receive the following error:

The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library. Error details: ERROR [42S02] [Microsoft][ODBC Excel Driver] The Microsoft Office Access database engine could not find the object 'Sheet1'. Make sure the object exists and that you spell its name and the path name correctly.

I've verified that the sheet name is spelled correctly (i.e. Sheet1) and I've verified that my data sources are set correctly.Web searches haven't turned up much at all.
[Code]....

View 5 Replies

Error: Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt?

Oct 11, 2010

I have both VS 2005 and 2008 installed on my machine. 2005 is fine. For 2008, literally any asp.net project I try to create gets this eror. I try stepping into the code, and the error occurs apparently before anything that I can trap is loaded. There is no information written to the event log. I have tried this with a "Hello World" webpage with nothing else going on. Seems unique to my Windows Server 2003 machine.

View 3 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory Is Corrupt

Jul 30, 2010

I am getting a weird error in asp.net while using leadtools imaging api. Here's the stack trace.

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at SetThreadData(_THREADDATA* )
at Leadtools.Codecs.CodecsOptions.Use()
at Leadtools.Codecs.RasterCodecs.DoSave(SaveParams saveParams)
at Leadtools.Codecs.RasterCodecs.Save(RasterImage image, Stream stream, RasterImageFormat format, Int32 bitsPerPixel)........

View 1 Replies

Attempted To Read Or Write Protected Memory. This Is Often An Indication That Other Memory?

Jan 26, 2011

I am maintaining C# .NET code written by somebody else, I get following exception few times,Attempted to read or write protected memory. This is often an indication that other memory is corruptThe code structure where I get the above exception is somethign like this,- it is using ref variables in following sequence,Variable-1 and variable-2 are local variables in App1, - App1: func1() which passes these variables reference to func2(), - App1: func2() passes same variables reference via .net remoting to another application (App2).-App2: does the same passes same received reference to another call 2 times.- The execption is occured while returning from App2.

(App1:func1(ref Var1, ref Var2) --> App1:func2(ref Var1, ref Var2) <---App1 .net remoting to App2--> App2:func3(ref Var1, ref Var2)--> App2:func4(ref Var1, ref Var2)-->variables getting updated and function returned to original caller)

My doubts are ,1. Is passing reference variables in such chain is correct? will it cause such exeption? Does .net support ref variable call directly?

View 1 Replies

Nhibernate Uses A Lot Of Memory?

Feb 9, 2011

I've got fluent nhibernate in my application and I'm trying to locate the cause of high memory usage. (I say high, it's 60MB, but it's a web app and it's not very big) Unfortunately it looks like a lot of it is in unmanaged memory, so I started taking things out - and as soon as I took out any calls to nhibernate, the memory usage dropped to 11MB!! Why oh why would it be taking up so much memory? Especially, why would it be taking up unmanaged memory?

I've been 'Googling' this all day and all I can find are posts from people saying "NHibernate eats memory..." and answers that say "no it doesn't, there's no evidence". Are NHibernate people in denial about it?

View 1 Replies

SQL Server :: How To Write A Stored Procedure For A Crud Application

Dec 4, 2010

How to write a stored procedure for a crud application in asp.net?

send me which is easily understandable...

View 3 Replies

C# - Trying To Unit Test The MembershipProvider?

Nov 21, 2010

I'm trying to unit test the MembershipProvider, however I cant figure out how or whether there is any need for unit testing of it...

My business layer:

public interface IAccountService
{
MembershipCreateStatus CreateUser(string userName, string password, string email);
}
public class AccountService : IAccountService
{
private readonly MembershipProvider provider;
public AccountService() : this(null) { }
public AccountService(MembershipProvider providera)
{
this.provider = providera ?? Membership.Provider;
}
public MembershipCreateStatus CreateUser(string userName, string password, string email)
{
if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", userName);
if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", password);
if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", email);
MembershipCreateStatus status;
provider.CreateUser(userName, password, email, null, null, true, null, out status);
return status;
}
}

The only examples I've found so far requires a "MockMembershipProvider" with a local database setup... seems quite odd to me.

View 1 Replies







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