Address CA1829 (Avoiding Count LINQ method calls when equivalent + more efficient properties exist) (#1961)

* Address CA1829 (Avoid Count LINQ Method Calls)

* Remove other change

* CA1829 removal

* CA1829 (remove whitespace)
This commit is contained in:
Chris LaFreniere
2023-03-23 21:06:49 -07:00
committed by GitHub
parent 3ef3a0f022
commit cccdbf0bef
15 changed files with 25 additions and 27 deletions

View File

@@ -217,7 +217,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
//Some tests still verify the number of backup sets that are executed which in some cases can be less than the selected list
if (verifyDatabase == null && selectedBackupSets != null)
{
Assert.AreEqual(selectedBackupSets.Count(), restoreDataObject.RestorePlanToExecute.RestoreOperations.Count());
Assert.AreEqual(selectedBackupSets.Length, restoreDataObject.RestorePlanToExecute.RestoreOperations.Count);
}
}
if (executionMode.HasFlag(TaskExecutionModeFlag.Script))

View File

@@ -240,7 +240,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
string targetDbName = testDb.DatabaseName;
bool canRestore = true;
var response = await VerifyRestore(backupFiles, null, canRestore, TaskExecutionModeFlag.None, targetDbName, null, null);
Assert.True(response.BackupSetsToRestore.Count() >= 2);
Assert.True(response.BackupSetsToRestore.Length >= 2);
var allIds = response.BackupSetsToRestore.Select(x => x.Id).ToList();
if (backupSetIndexToDelete >= 0)
{
@@ -269,7 +269,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
return true;
});
for (int i = 0; i < response.BackupSetsToRestore.Count(); i++)
for (int i = 0; i < response.BackupSetsToRestore.Length; i++)
{
DatabaseFileInfo databaseInfo = response.BackupSetsToRestore[i];
Assert.AreEqual(databaseInfo.IsSelected, expectedSelectedIndexes.Contains(i));
@@ -337,7 +337,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
bool canRestore = true;
var response = await VerifyRestore(backupFileNames, null, canRestore, TaskExecutionModeFlag.None, "RestoredFromTwoBackupFile");
Assert.True(response.BackupSetsToRestore.Count() == 2);
Assert.True(response.BackupSetsToRestore.Length == 2);
}
//[Test]
@@ -347,7 +347,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
bool canRestore = true;
var response = await VerifyRestore(backupFileNames, null, canRestore, TaskExecutionModeFlag.None, "RestoredFromTwoBackupFile");
Assert.True(response.BackupSetsToRestore.Count() == 2);
Assert.True(response.BackupSetsToRestore.Length == 2);
var fileInfo = response.BackupSetsToRestore.FirstOrDefault(x => x.GetPropertyValueAsString(BackupSetInfo.BackupTypePropertyName) != RestoreConstants.TypeFull);
if (fileInfo != null)
{
@@ -363,7 +363,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
string[] backupFileNames = new string[] { "FullBackup.bak", "DiffBackup.bak" };
bool canRestore = true;
var response = await VerifyRestore(backupFileNames, null, canRestore, TaskExecutionModeFlag.None, "RestoredFromTwoBackupFile");
Assert.True(response.BackupSetsToRestore.Count() == 2);
Assert.True(response.BackupSetsToRestore.Length == 2);
var fileInfo = response.BackupSetsToRestore.FirstOrDefault(x => x.GetPropertyValueAsString(BackupSetInfo.BackupTypePropertyName) == RestoreConstants.TypeFull);
if (fileInfo != null)
{
@@ -662,7 +662,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.DisasterRecovery
//Some tests still verify the number of backup sets that are executed which in some cases can be less than the selected list
if (verifyDatabase == null && selectedBackupSets != null)
{
Assert.That(restoreDataObject.RestorePlanToExecute.RestoreOperations.Count(), Is.EqualTo(selectedBackupSets.Count()), $"{nameof(restoreDataObject.RestorePlanToExecute.RestoreOperations)} contains different number of objects than {nameof(selectedBackupSets)}");
Assert.That(restoreDataObject.RestorePlanToExecute.RestoreOperations.Count, Is.EqualTo(selectedBackupSets.Length), $"{nameof(restoreDataObject.RestorePlanToExecute.RestoreOperations)} contains different number of objects than {nameof(selectedBackupSets)}");
}
}
if (executionMode.HasFlag(TaskExecutionModeFlag.Script))