#region Copyright (C) 2003 Yuriy Baltovskyy <bym@itcs.com.ua>
/*
* Ormyx for .NET - Object Relational Mapping
* Copyright (C) 2003 Yuriy Baltovskyy
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#endregion
using System;
using NUnit.Framework;
using Ormyx.UnitTest.Domain;
using Ormyx.UnitTest.Domain.Mapping;
namespace Ormyx.UnitTest.Tests.Writer.Delete{
/// <summary>
/// Summary description for DeleteMtoMCollectionTF.
/// </summary>
[TestFixture]
public class DeleteMtoMCollectionTF : BaseTest
{
[SetUp]
protected override void SetUp()
{
base.SetUp();
Session.RegisterMapping(typeof(Employer), new EmployerProjectLeftJoinMapping().ClassMapping);
}
[Test]
public void TestDelete1()
{
Project project1 = new Project("Test project 1");
Project project2 = new Project("Test project 2");
BeginTransaction();
Session.Save(project1);
Session.Save(project2);
CommitTransaction();
Employer employer = new Employer("Test employer", "Test employer", Gender.Male);
employer.Add(project1);
employer.Add(project2);
AssertInsertAndDelete(employer, FinderFactory.EmployerProjectLeftJoinFinder);
Assert.IsNotNull(FinderFactory.ProjectFinder.Find(Session, project1.Id));
}
[Test]
public void TestDelete2()
{
Session.RegisterMapping(typeof(Employer), new EmployerLeftJoinMapping().ClassMapping);
Employer employer = CreateEmployer(2, 1);
AssertInsertAndDelete(employer, FinderFactory.EmployerLeftJoinFinder);
//two child employers still exist
Assert.IsNotNull(FinderFactory.EmployerLeftJoinFinder.Find(Session, (employer.EmployerList[0] as DomainObject).Id));
Assert.IsNotNull(FinderFactory.EmployerLeftJoinFinder.Find(Session, (employer.EmployerList[1] as DomainObject).Id));
}
}
}
|