1

I am new to testing and new to JustMock.

I have written my first test.

    [TestMethod]
    public void CheckifExportToCSVIsSuccessfull()
    {
        C1FlexGrid c1flexGrid = new C1FlexGrid();
        
        C1FlexGridBase c1flexGridBase = (C1FlexGridBase)(c1flexGrid);

        Timeslice.ComponentOneExtensions.C1FlexGridExtensions.ExportResult expected = Timeslice.ComponentOneExtensions.C1FlexGridExtensions.ExportResult.Succeeded;

        Mock.Arrange(() => c1flexGridBase.ExportToCSV($"")).Returns(Timeslice.ComponentOneExtensions.C1FlexGridExtensions.ExportResult.Failed);

        // Assert 
        Assert.AreEqual(expected, c1flexGridBase.ExportToCSV($""));
    }

Here is the function it is testing.

     public static ExportResult ExportToCSV(this C1FlexGridBase c1FlexGrid, string fileName)
    {
        c1FlexGrid.SaveGrid(fileName, FileFormatEnum.TextComma, FileFlags.IncludeFixedCells);
        return ExportResult.Succeeded;
    }

The test works as it is failing.

I don't understand what the Arrange is supposed to do.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
Shezad Ahmed
  • 69
  • 1
  • 6

0 Answers0