title: How to write an Assert statement for collection in Xunit?
body: <p>I'm using an xUnit test framework to write some unit test.  Below is a code snippet which test if <code>azColumns</code> collection is empty or not.  However, I was thinking is there a better way to assert <code>azColumns</code> collection without using two <code>Assert</code> inside an <code>if..else</code> block statement?</p>
  
  <p>Maybe a one liner <code>Assert</code> statement that makes sense?</p>
  
  <pre><code>private static string LoadJsonFile()
  {
      const string fileName = "templateFileContent_1.json";
      var filePath = Path.Combine(Directory.GetCurrentDirectory(), $@"Data\{fileName}");
  
      return !File.Exists(filePath) ? string.Empty : filePath;
  }
  
  private static string GetJsonData()
  {
      JObject jsonObject;
      var jsonFile = LoadJsonFile();
  
      if (string.IsNullOrEmpty(jsonFile)) return string.Empty;
  
      using (var reader = new StreamReader(jsonFile))
      {
          var jsonData = reader.ReadToEnd();
          jsonObject = JObject.Parse(jsonData);
      }
  
      return jsonObject.ToString();
  }
  
  private static JObject GetBaseConfigurationObject()
  {
      var json = GetJsonData();
  
      if (string.IsNullOrEmpty(json)) return null;
  
      var baseObject = JsonConvert.DeserializeObject&lt;JObject&gt;(json);
      return baseObject;
  }
  
  [Fact]
  public void ExportColumns_Should_Not_Be_Empty_Or_Null()
  {
      // Arrange
      IEnumerable&lt;az_Columns&gt; azColumns = null;
  
      // Act
      var baseConfig = GetBaseConfigurationObject();
      var fileContent = baseConfig?["templateFileContent"];
  
      if (fileContent != null)
      {
          var baseConfiguration = fileContent.ToObject&lt;BaseConfiguration&gt;();
          azColumns = baseConfiguration?.ExportData?.az_Columns;
      }
  
      // Assert
      if (azColumns == null)
      {
          Assert.Null(azColumns);
      }
      else
      {
          Assert.NotEmpty(azColumns);
      }
  }
  </code></pre>
  
  <p>Any inputs is greatly appreciated.</p>