Mock.Arrange what does it actually do?

1.1k Views Asked by At

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.

0

There are 0 best solutions below