Skip to main content
added 10 characters in body; edited tags; edited title
Source Link
Jamal
  • 35.4k
  • 13
  • 135
  • 240

Am i Possible fake testing or this is how mocking should be implemented?with Rhino mock

I'm new to Rhino mock and iI would like to know if the test iI did is not fake testing, as i redI've read a lot about it. areAre there any improvements that need to be done?

[Test]
public void GenerateDateTable_Returns_DataTableOfGroup()
{
    //Arrange
    var groupStub = MockRepository.GenerateStub<Group>();
    var groupEnumerable = new[] { groupStub };
    var mockgroup = MockRepository.GenerateMock<FillTableRow<Group>>();
    mockgroup.Replay();
    //Act
    mockgroup.GenerateDateTable(groupEnumerable);

    //Assert
    Assert.IsTrue(mockgroup.DataTableBatch.Columns.Count == 3);
}

public class FillTableRow<T>
{
    public DataTable DataTableBatch { get; set; }

    public DataTable GenerateDateTable(IEnumerable<T> enumerable)
    {
        IDbObjectFactory<T> tableFactory = new TableFactory<T>();
        DataTableBatch = (DataTable)tableFactory.GetDbObject();

        foreach (var row in enumerable)
        {
            AddRow(row);
        }
        return DataTableBatch;
    }
}

Am i fake testing or this is how mocking should be implemented?

I'm new to Rhino mock and i would like to know if the test i did is not fake testing as i red a lot about it. are there any improvements need to be done?

[Test]
public void GenerateDateTable_Returns_DataTableOfGroup()
{
    //Arrange
    var groupStub = MockRepository.GenerateStub<Group>();
    var groupEnumerable = new[] { groupStub };
    var mockgroup = MockRepository.GenerateMock<FillTableRow<Group>>();
    mockgroup.Replay();
    //Act
    mockgroup.GenerateDateTable(groupEnumerable);

    //Assert
    Assert.IsTrue(mockgroup.DataTableBatch.Columns.Count == 3);
}

public class FillTableRow<T>
{
    public DataTable DataTableBatch { get; set; }

    public DataTable GenerateDateTable(IEnumerable<T> enumerable)
    {
        IDbObjectFactory<T> tableFactory = new TableFactory<T>();
        DataTableBatch = (DataTable)tableFactory.GetDbObject();

        foreach (var row in enumerable)
        {
            AddRow(row);
        }
        return DataTableBatch;
    }
}

Possible fake testing with Rhino mock

I'm new to Rhino mock and I would like to know if the test I did is not fake testing, as I've read a lot about it. Are there any improvements that need to be done?

[Test]
public void GenerateDateTable_Returns_DataTableOfGroup()
{
    //Arrange
    var groupStub = MockRepository.GenerateStub<Group>();
    var groupEnumerable = new[] { groupStub };
    var mockgroup = MockRepository.GenerateMock<FillTableRow<Group>>();
    mockgroup.Replay();
    //Act
    mockgroup.GenerateDateTable(groupEnumerable);

    //Assert
    Assert.IsTrue(mockgroup.DataTableBatch.Columns.Count == 3);
}

public class FillTableRow<T>
{
    public DataTable DataTableBatch { get; set; }

    public DataTable GenerateDateTable(IEnumerable<T> enumerable)
    {
        IDbObjectFactory<T> tableFactory = new TableFactory<T>();
        DataTableBatch = (DataTable)tableFactory.GetDbObject();

        foreach (var row in enumerable)
        {
            AddRow(row);
        }
        return DataTableBatch;
    }
}
Tweeted twitter.com/#!/StackCodeReview/status/322347017307295745
Source Link
Maro
  • 123
  • 3

Am i fake testing or this is how mocking should be implemented?

I'm new to Rhino mock and i would like to know if the test i did is not fake testing as i red a lot about it. are there any improvements need to be done?

[Test]
public void GenerateDateTable_Returns_DataTableOfGroup()
{
    //Arrange
    var groupStub = MockRepository.GenerateStub<Group>();
    var groupEnumerable = new[] { groupStub };
    var mockgroup = MockRepository.GenerateMock<FillTableRow<Group>>();
    mockgroup.Replay();
    //Act
    mockgroup.GenerateDateTable(groupEnumerable);

    //Assert
    Assert.IsTrue(mockgroup.DataTableBatch.Columns.Count == 3);
}

public class FillTableRow<T>
{
    public DataTable DataTableBatch { get; set; }

    public DataTable GenerateDateTable(IEnumerable<T> enumerable)
    {
        IDbObjectFactory<T> tableFactory = new TableFactory<T>();
        DataTableBatch = (DataTable)tableFactory.GetDbObject();

        foreach (var row in enumerable)
        {
            AddRow(row);
        }
        return DataTableBatch;
    }
}