Skip to content

Commit

Permalink
DYN-7963 Obsolote Excel Interop Node - Code Review
Browse files Browse the repository at this point in the history
I've updated the Category to contains ExcelTest and also the new Category ExcelTestInterop.
Also there was one test using the decorator Obsolete so I removed that decorator due that is not well tested.
  • Loading branch information
RobertGlobant20 committed Jan 8, 2025
1 parent 2053c22 commit e4af9e6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 40 deletions.
1 change: 0 additions & 1 deletion src/Libraries/DSOffice/Excel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ public static object[][] ImportExcel(FileInfo file, string sheetName, bool readA
/// <returns name="data">Data written to the spreadsheet</returns>
/// <search>office,excel,spreadsheet</search>
[NodeObsolete("ExcelInteropObsoleteNode", typeof(Properties.Resources))]
[Obsolete("Use ExportToExcel instead.")]
public static object[][] ExportExcel(string filePath, string sheetName, int startRow, int startColumn, object[][] data, bool overWrite = false)
{
return ExcelWriteUtils.WriteData(filePath, sheetName, startRow, startColumn, data, overWrite);
Expand Down
76 changes: 38 additions & 38 deletions test/Libraries/DynamoMSOfficeTests/ExcelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override void Cleanup()

#region COM

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ExcelAppIsClosedOnCleanup()
{
Assert.Inconclusive("Has trouble with sequential unit tests. Does work with single unit test, though.");
Expand All @@ -79,7 +79,7 @@ public void ExcelAppIsClosedOnCleanup()

#region Reading

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanGetLargeWorkbookWithinThresholdTime()
{

Expand All @@ -102,7 +102,7 @@ public void CanGetLargeWorkbookWithinThresholdTime()
}


[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanGetWorksheets()
{

Expand All @@ -124,7 +124,7 @@ public void CanGetWorksheets()
Assert.AreEqual(3, mirror.GetElements().ToList().Count);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanGetWorksheetByNameWithValidInput()
{

Expand All @@ -145,7 +145,7 @@ public void CanGetWorksheetByNameWithValidInput()
Assert.IsNotNull(watch.CachedValue);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ThrowExceptionOnGetWorksheetByNameWithInvalidInput()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WorksheetByName_InvalidInput.dyn");
Expand All @@ -165,7 +165,7 @@ public void ThrowExceptionOnGetWorksheetByNameWithInvalidInput()
Assert.IsNull(getWorksheet.CachedValue.Data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadWorksheetWithSingleColumnOfNumbers()
{

Expand Down Expand Up @@ -198,7 +198,7 @@ public void CanReadWorksheetWithSingleColumnOfNumbers()
}
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]

public void CanReadMultiDimensionalWorksheet()
{
Expand Down Expand Up @@ -234,7 +234,7 @@ public void CanReadMultiDimensionalWorksheet()
}
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadWorksheetWithEmptyCellInUsedRange()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\DataFromFile_missingCell.dyn");
Expand All @@ -251,7 +251,7 @@ public void CanReadWorksheetWithEmptyCellInUsedRange()
AssertPreviewValue(watch.GUID.ToString(), data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadWorksheetWithMixedNumbersAndStrings()
{

Expand All @@ -273,7 +273,7 @@ public void CanReadWorksheetWithMixedNumbersAndStrings()
AssertPreviewValue(watch.GUID.ToString(), data);

}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ReadOnlyFile()
{
//Read from readonly Excel file and make sure Excel node in Dynamo displays value correctly.
Expand All @@ -291,7 +291,7 @@ public void ReadOnlyFile()
AssertPreviewValue(watch.GUID.ToString(), data);

}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadAndWriteExcel()
{

Expand Down Expand Up @@ -320,7 +320,7 @@ public void CanReadAndWriteExcel()


}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ReadChangeFilename()
{

Expand Down Expand Up @@ -359,7 +359,7 @@ public void ReadChangeFilename()
AssertPreviewValue(watch.GUID.ToString(), data);

}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ReadNonExistingFile()
{

Expand All @@ -384,7 +384,7 @@ public void ReadNonExistingFile()
}


[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadExcelAsStrings()
{

Expand All @@ -408,7 +408,7 @@ public void CanReadExcelAsStrings()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanReadEmptyCellsAsStrings()
{

Expand Down Expand Up @@ -452,7 +452,7 @@ public void CanReadEmptyCellsAsStrings()

#region Writing

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWrite1DDataOfMixedTypesToExcelWorksheet()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_AddMixed1DData.dyn");
Expand All @@ -468,7 +468,7 @@ public void CanWrite1DDataOfMixedTypesToExcelWorksheet()
AssertPreviewValue(watch.GUID.ToString(), data);

}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void Excel_MAGN6872()
{
// http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-6872
Expand Down Expand Up @@ -523,7 +523,7 @@ public void Excel_MAGN6872()
Assert.AreEqual(new object[] { 1.00, 2.00, 3.00, 4.00, 5.00, null, null }, dataList3);

}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void Excel_OverwriteWithnull_7213()
{
// Overwrite the excel sheet with null values and it must work ok.
Expand All @@ -546,7 +546,7 @@ public void Excel_OverwriteWithnull_7213()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void Excel_OverWriteEmptyList_MAGN7213()
{

Expand All @@ -569,7 +569,7 @@ public void Excel_OverWriteEmptyList_MAGN7213()


}
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanCreateNewWorksheetInNewWorkbook()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_AddWorksheet.dyn");
Expand All @@ -580,7 +580,7 @@ public void CanCreateNewWorksheetInNewWorkbook()
Assert.IsNull(getWorksheet.CachedValue.Data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanAddSingleItemToExcelWorksheet()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_AddSingleItemData.dyn");
Expand All @@ -604,7 +604,7 @@ public void CanAddSingleItemToExcelWorksheet()
/// <summary>
/// This test method will execute the Excel.WriteDataToExcelWorksheet method trying to write a null value in a excel file
/// </summary>
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanAddNullItemToExcelWorksheet()
{
//Arrange
Expand All @@ -623,7 +623,7 @@ public void CanAddNullItemToExcelWorksheet()
Assert.IsNull(watch.CachedValue.Data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanAdd1DListToExcelWorksheet()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_Add1DListData.dyn");
Expand Down Expand Up @@ -651,7 +651,7 @@ public void CanAdd1DListToExcelWorksheet()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanAdd2DListToExcelWorksheet()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_Add2DListData.dyn");
Expand Down Expand Up @@ -681,7 +681,7 @@ public void CanAdd2DListToExcelWorksheet()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteToExcelAndUpdateData()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteNodeAndUpdateData.dyn");
Expand Down Expand Up @@ -726,7 +726,7 @@ public void CanWriteToExcelAndUpdateData()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteJaggedArrayToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteJaggedArrayToExcel.dyn");
Expand All @@ -751,7 +751,7 @@ public void CanWriteJaggedArrayToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteEmptyArrayToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteEmptyArrayToExcel.dyn");
Expand All @@ -774,7 +774,7 @@ public void CanWriteEmptyArrayToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteNestedEmptyListToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteNestedEmptyListToExcel.dyn");
Expand All @@ -800,7 +800,7 @@ public void CanWriteNestedEmptyListToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteEmptyListToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteEmptyListToExcel.dyn");
Expand All @@ -824,7 +824,7 @@ public void CanWriteEmptyListToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanOverWriteToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\OverWriteExcelSheet.dyn");
Expand Down Expand Up @@ -852,7 +852,7 @@ public void CanOverWriteToExcel()
AssertPreviewValue(writeNode.GUID.ToString(), data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanOverWritePartiallyToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\OverWritePartialExcelSheet.dyn");
Expand Down Expand Up @@ -883,7 +883,7 @@ public void CanOverWritePartiallyToExcel()
AssertPreviewValue(writeNode.GUID.ToString(), data);
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteNullValueToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteNullValuesToExcel.dyn");
Expand All @@ -906,7 +906,7 @@ public void CanWriteNullValueToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanWriteNullValueInListToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteNullValuesToExcel1.dyn");
Expand All @@ -928,7 +928,7 @@ public void CanWriteNullValueInListToExcel()

}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void TestWriteFunctionObjectToExcel()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\WriteFunctionobject.dyn");
Expand Down Expand Up @@ -1057,7 +1057,7 @@ public void WriteToReadOnlyFile()
/// <summary>
/// This will execute the Data.ImportExcel method
/// </summary>
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ImportExcelShowExcelReturnDataObjectArray()
{
//Arrange
Expand Down Expand Up @@ -1184,7 +1184,7 @@ public void TestOverwriteToSingleSheetExcel()
}


[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanExportToExcelAsString()
{
// Arrange
Expand Down Expand Up @@ -1221,7 +1221,7 @@ public void CanExportToExcelAsString()

#region Saving

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void CanSaveAsWorksheet()
{
string openPath = Path.Combine(TestDirectory, @"core\excel\NewWorkbook_SaveAs.dyn");
Expand Down Expand Up @@ -1250,7 +1250,7 @@ public void CanSaveAsWorksheet()
/// for an enhancement which allows "Watch.GenerateWatchViewModelForData" to be called (and
/// crash without the fix).
/// </summary>
[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void Defect_MAGN_883()
{
string testDir = TestDirectory;
Expand Down
2 changes: 1 addition & 1 deletion test/Libraries/WorkflowTests/DynamoSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public void ImportExport_CSV_to_Stuff()
}
}

[Test, Category("ExcelTestInterop")]
[Test, Category("ExcelTest"), Category("ExcelTestInterop")]
public void ImportExport_Data_To_Excel()
{
OpenSampleModel(@"en-US\ImportExport\ImportExport_Data To Excel.dyn");
Expand Down

0 comments on commit e4af9e6

Please sign in to comment.