public MacQueryTests()
        {
            _given = () =>
                     	{
                     		companyA = new EntityReference("companies/123", "CompanyDescription");
                     		companyAChart = new Chart() {Company = companyA};
                     		companyB = new EntityReference("companies/456", "CompanyDescription");
                     		companyBChart = new Chart() {Company = companyB};

                     		_session.Store(companyAChart);
                     		_session.Store(companyBChart);
                     	};
        }
 public static bool HasAccessTo(this User user, Chart chart)
 {
     return user.Roles.Contains(Roles.SiteAdministrator)
      	       || user.Company == chart.Company;
 }
 private void Validate(Chart chart)
 {
     if (string.IsNullOrWhiteSpace(chart.Name))
     {
         throw new InvalidChartException("Name cannot be empty.");
     }
     if (!chart.Items.Any())
     {
         throw new InvalidChartException("The chart must have at least one item in it.");
     }
 }