public void When_saving_should_write_to_database() { var config = new DataConfig(); config.PerformStartup(); config.StartSession(); var visitor = new Visitor { Browser = "1", IpAddress = "2", LoginName = "3", PathAndQuerystring = "4", VisitDate = new DateTime(2000, 1, 1) }; var repository = new VisitorRepository(); repository.Save(visitor); config.EndSession(); config.StartSession(); ISession session = new SessionCache().GetSession(); var loadedVisitor = session.Load<Visitor>(visitor.Id); Assert.That(loadedVisitor, Is.Not.Null); Assert.That(loadedVisitor.Browser, Is.EqualTo("1")); Assert.That(loadedVisitor.IpAddress, Is.EqualTo("2")); Assert.That(loadedVisitor.LoginName, Is.EqualTo("3")); Assert.That(loadedVisitor.PathAndQuerystring, Is.EqualTo("4")); Assert.That(loadedVisitor.VisitDate, Is.EqualTo(new DateTime(2000, 1, 1))); }
public Visitor BuildVisitor() { var visitor = new Visitor { PathAndQuerystring = _httpRequest.Url.PathAndQuery, Browser = _httpRequest.UserAgent, IpAddress = _httpRequest.UserHostAddress, LoginName = _httpRequest.LogonUserIdentity.Name, VisitDate = _currentDate }; return visitor; }
public void Save(Visitor visitor) { ISession session = GetSession(); session.SaveOrUpdate(visitor); }