Added more model tests and fixed the calculations for nPlacedBiddings, biddingSum and totalSharesWithBiddings if there are conflicting entries (shareType: "erarbeitet" but a bidding is placed).
This commit is contained in:
@ -15,10 +15,56 @@ struct ModelTest : testing::Test {
|
||||
|
||||
ModelTest() { model = make_shared<TableModel>(new QUndoStack()); }
|
||||
|
||||
~ModelTest() {}
|
||||
virtual ~ModelTest() {}
|
||||
};
|
||||
|
||||
TEST_F(ModelTest, TestRowCount) {
|
||||
struct ModelTestWithData : ModelTest {
|
||||
ModelTestWithData() {
|
||||
QList<ModelItemValues> itemList;
|
||||
|
||||
ModelItemValues itemValues1 = {{Bidding1Role, 100},
|
||||
{ShareTypeRole, "bezahlt"},
|
||||
{ShareAmountRole, 1},
|
||||
{BiddingTypeRole, "digital"}};
|
||||
itemList.append(itemValues1);
|
||||
|
||||
ModelItemValues itemValues2 = {{Bidding1Role, 100},
|
||||
{ShareTypeRole, "bezahlt"},
|
||||
{ShareAmountRole, 1},
|
||||
{BiddingTypeRole, ""}};
|
||||
itemList.append(itemValues2);
|
||||
|
||||
ModelItemValues itemValues3 = {{Bidding1Role, 50},
|
||||
{ShareTypeRole, "teils/teils"},
|
||||
{ShareAmountRole, 1},
|
||||
{BiddingTypeRole, "paper"}};
|
||||
itemList.append(itemValues3);
|
||||
|
||||
ModelItemValues itemValues4 = {{Bidding1Role, 50},
|
||||
{ShareTypeRole, "bezahlt"},
|
||||
{ShareAmountRole, 0.5},
|
||||
{BiddingTypeRole, "paper"}};
|
||||
itemList.append(itemValues4);
|
||||
|
||||
ModelItemValues itemValues5 = {{Bidding1Role, 100},
|
||||
{ShareTypeRole, "erarbeitet"},
|
||||
{ShareAmountRole, 1},
|
||||
{BiddingTypeRole, "paper"}};
|
||||
itemList.append(itemValues5);
|
||||
|
||||
ModelItemValues itemValues6 = {{Bidding1Role, 0},
|
||||
{ShareTypeRole, "bezahlt"},
|
||||
{ShareAmountRole, 1},
|
||||
{BiddingTypeRole, "online"}};
|
||||
itemList.append(itemValues6);
|
||||
|
||||
model->insertItems(0, itemList);
|
||||
}
|
||||
};
|
||||
|
||||
/// empty model
|
||||
|
||||
TEST_F(ModelTest, TestRowCountEmpty) {
|
||||
const int expectedRowCount = 0;
|
||||
|
||||
const auto actualRowCount = model->rowCount();
|
||||
@ -32,3 +78,40 @@ TEST_F(ModelTest, TestBidding1Average) {
|
||||
|
||||
ASSERT_EQ(expected, actualBidding1Average);
|
||||
}
|
||||
|
||||
TEST_F(ModelTest, ExpectedPlacedBiddings) {
|
||||
const int expected = 0;
|
||||
const auto expectedPlacedBiddings = model->nExpectedBiddings();
|
||||
|
||||
ASSERT_EQ(expected, expectedPlacedBiddings);
|
||||
}
|
||||
|
||||
/// model with data
|
||||
|
||||
TEST_F(ModelTestWithData, TestRowCount) {
|
||||
const int expected = 6;
|
||||
|
||||
const auto actual = model->rowCount();
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST_F(ModelTestWithData, TestBidding1Average) {
|
||||
const qreal expected = 100;
|
||||
const auto actual = model->biddingAverage1();
|
||||
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST_F(ModelTestWithData, ExpectedPlacedBiddings) {
|
||||
const int expected = 4;
|
||||
const auto actual = model->nExpectedBiddings();
|
||||
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST_F(ModelTestWithData, PlacedBiddings1) {
|
||||
const int expected = 3;
|
||||
const auto actual = model->nPlacedBiddings1();
|
||||
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user