Joe,Thanks for the patch.
Can you also provide a couple of unit tests to go along with it?
On Mon, Oct 27, 2008 at 6:21 PM, Joe <[EMAIL PROTECTED]> wrote:
>
> I was working with Rhino.Commons this weekend and needed to test a
> query I was working with. I had two problems.
>
> 1. My SQLServer was a named instanced server so the server value
> (local) in the connection string would not work. Its hardcoded in
> UnitOfWorkTestContextDbStrategy.cs. I needed (local)\SQL2005.
> 2. I already had the schema and did not want Rhino.Commons to try to
> recreate it.
>
> So I wrote a patch to DatabaseTestFixtureBase and
> UnitOfWorkTestContextDbStrategy that allows me to specify a server
> name and a bool flag to determine whether or not to create the schema.
>
> Now, I have never created a patch before, so if I hosed this up, let
> me know and I will do what I can to fix it.
> Also, if I am doing something completely wrong, can some one please
> let me know. This has been a helluva learning experience for me, so I
> am sure I am missing something. :D
> I have uploaded the patch and it allows me to create my tests as such:
>
> [TestFixture]
> public class CustomerServiceFixture : DatabaseTestFixtureBase
> {
> #region Setup/Teardown
>
> [SetUp]
> public void TestSetUp()
> {
> CurrentContext.CreateUnitOfWork();
>
> var customer = new CustomerEntity
> {
> FirstName = "Joe",
> LastName = "Young"
> };
>
> UnitOfWork.CurrentSession.Save(customer);
> UnitOfWork.CurrentSession.Flush();
> }
>
> [TearDown]
> public void TestTearDown()
> {
> Repository<CustomerEntity>.DeleteAll();
> CurrentContext.DisposeUnitOfWork();
> }
>
> #endregion
>
> [TestFixtureSetUp]
> public void TestFixtureSetup()
> {
>
> IntializeNHibernateAndIoC(PersistenceFramework.ActiveRecord,
> //
> Persistence Framework
>
> "Windsor.boo", // Configuration
>
> DatabaseEngine.MsSql2005, // Database Type
>
> "SandBox_Dev", // Database Name
> @"(local)
> \SQL2005", // Server Name
>
> false, // Create Schema
>
> MappingInfo.FromAssemblyContaining<Entity>(), // AR Entities
>
> null); // Additional NH
> Properties
> }
>
> [Test]
> public void CanFetchCustomer()
> {
> var criteria = DetachedCriteria.For(typeof
> (CustomerEntity));
> criteria.Add(Restrictions.Eq("LastName", "Young"));
>
> var customer =
> Repository<CustomerEntity>.FindFirst(criteria, new[]
> {Order.Asc("LastName")});
>
> Assert.IsNotNull(customer);
> }
> }
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---