/// <summary>
        /// Called to 'call home' to ensure the current server has an active record
        /// </summary>
        /// <param name="address"></param>
        public void EnsureActive(string address)
        {

            var uow = _uowProvider.GetUnitOfWork();
            using (var repo = _repositoryFactory.CreateServerRegistrationRepository(uow))
            {
                //NOTE: we cannot use Environment.MachineName as this does not work in medium trust
                // found this out in CDF a while back: http://clientdependency.codeplex.com/workitem/13191

                var computerName = System.Net.Dns.GetHostName();
                var query = Query<ServerRegistration>.Builder.Where(x => x.ComputerName.ToUpper() == computerName.ToUpper());
                var found = repo.GetByQuery(query).ToArray();
                ServerRegistration server;
                if (found.Any())
                {
                    server = found.First();
                    server.ServerAddress = address; //This should not  really change but it might!
                    server.UpdateDate = DateTime.UtcNow; //Stick with Utc dates since these might be globally distributed
                    server.IsActive = true;
                }
                else
                {
                    server = new ServerRegistration(address, computerName, DateTime.UtcNow);
                }
                repo.AddOrUpdate(server);
                uow.Commit();
            }
        }
        public void Cannot_Add_Duplicate_Computer_Names()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();

            // Act
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER1", DateTime.Now);
                repository.AddOrUpdate(server);

                Assert.Throws<SqlCeException>(unitOfWork.Commit);
            }

        }
        public void Can_Perform_Add_On_Repository()
        {
            // Arrange
            var provider = new PetaPocoUnitOfWorkProvider();
            var unitOfWork = provider.GetUnitOfWork();
            using (var repository = new ServerRegistrationRepository(unitOfWork))
            {
                // Act
                var server = new ServerRegistration("http://shazwazza.com", "COMPUTER4", DateTime.Now);
                repository.AddOrUpdate(server);
                unitOfWork.Commit();

                // Assert
                Assert.That(server.HasIdentity, Is.True);
                Assert.That(server.Id, Is.EqualTo(4));//With 3 existing entries the Id should be 4   
            }            
        }