using System; using System.Collections.Generic; using System.Text; using NUnit.Framework; using NHibernate.Criterion; using InfoCenter.Persistence.Core; using InfoCenter.Persistence.Entities; namespace InfoCenter.Persistence.Tests { [TestFixture] public class Test_Computer : Base_Fixture { IRepository<Computer> repository; Computer computer1; [TestFixtureSetUp] public void Test_Construction() { base.TestFixtureSetUp(); repository = new Repository<Computer>(SessionFactory); Assert.IsNotNull(repository, "Cannot get repository"); computer1 = new Computer(); computer1.Name = "Computer1"; computer1.Ip = "192.168.1.1"; computer1.OsVersion = "Os1"; computer1.UserName = "User1"; computer1.RecentActivity = DateTime.Now; } [Test] public void CanAdd() { base.TestFixtureSetUp(); //Test_Construction(); repository.Add(computer1); } [Test] public void CanGet() { //var comp = repository.FindOne(c => c.Name == "Computer1"); DetachedCriteria criteria = DetachedCriteria.For<Computer>() .Add(NHibernate.Criterion.Expression.Like("Name","Computer1")); Computer comp = repository.FindOne(criteria); Assert.NotNull(comp, "Query doesn't work"); Assert.AreEqual(computer1.Name, comp.Name, "Name mismatch"); Assert.AreEqual(computer1.Ip, comp.Ip, "Ip mismatch"); } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)