- infocenter.zip
- InfoCenter
- ConfigSamples
- InfoCenter.Agent
- InfoCenter.Logic.Tests
- InfoCenter.Logic
- Agent
- Entities
- Helpers
- bin
- Debug
- Antlr3.Runtime.dll
- hibernate.cfg.xml
- Iesi.Collections.dll
- InfoCenter.Logic.dll
- InfoCenter.Logic.dll.mdb
- InfoCenter.Logic.pdb
- InfoCenter.Persistence.dll
- InfoCenter.Persistence.dll.mdb
- InfoCenter.Persistence.pdb
- log4net.dll
- Release
- InfoCenter.Logic.csproj
- InfoCenter.Logic.pidb
- obj
- Debug
- PacketParser.cs
- Properties
- InfoCenter.Persistence.Test
- InfoCenter.Persistence
- InfoCenter.sln
- InfoCenter.userprefs
- InfoCenter.WebConsole
- SharedLibs
- Antlr3.Runtime.dll
- Castle.Core.dll
- Castle.DynamicProxy2.dll
- Iesi.Collections.dll
- log4net.dll
- MySql.Data.dll
- NHibernate.ByteCode.Castle.dll
- NHibernate.dll
- nunit.framework.dll
- test-results
|
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_Process:Base_Fixture
{
IRepository<Computer> computers;
IRepository<Process> processes;
[TestFixtureSetUp]
public void Test_Construction()
{
base.TestFixtureSetUp();
computers = new Repository<Computer>(SessionFactory);
processes = new Repository<Process>(SessionFactory);
}
[Test]
public void CanAdd()
{
base.TestFixtureSetUp();
//this.Test_Construction();
//Add computer
Computer computer =new Computer();
computer.Name = "Computer1";
computer.UserName = "User1";
computer.RecentActivity = DateTime.Now;
computers.Add(computer);
Process process = new Process();
process.Host = computer;
process.Pid = 1;
process.Name = "ProcessName1";
processes.Add(process);
}
[Test]
public void CanGetByName()
{
//Process process = processes.FindOne(p => p.Name == "ProcessName1");
DetachedCriteria criteria = DetachedCriteria.For<Process>()
.Add(NHibernate.Criterion.Expression.Like("Name","ProcessName1"));
Process process = processes.FindOne(criteria);
Assert.NotNull(process, "Can't get process");
Assert.AreEqual("ProcessName1", process.Name, "Process name is invalid");
}
[Test]
public void CanGetByComputer()
{
//Process process = processes.FindOne(p => p.Host.Name == "Computer1");
DetachedCriteria criteria = DetachedCriteria.For<Process>().CreateAlias("Host","c")
.Add(NHibernate.Criterion.Expression.Eq("c.Name","Computer1"));
Process process = processes.FindOne(criteria);
Assert.NotNull(process, "Can't get process");
Assert.AreEqual("ProcessName1", process.Name, "Process name is invalid");
Assert.AreEqual("Computer1", process.Host.Name, "Process hostname is invalid");
}
}
}
|
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.
Interested in design/development of framework functionality using the best patterns and practices.