56 lines
2.4 KiB
Dart
56 lines
2.4 KiB
Dart
|
import 'package:cpd_2022_energy/provider/energy_model.dart';
|
||
|
import 'package:flutter_test/flutter_test.dart';
|
||
|
|
||
|
void main() {
|
||
|
EnergyModel model = EnergyModel();
|
||
|
|
||
|
const double heightStart = 50.0;
|
||
|
const double heightEnd = 10.0;
|
||
|
const double velocityStart = 0.0;
|
||
|
const double velocityEnd = 40.0;
|
||
|
const double weight = 777.0;
|
||
|
|
||
|
group('Test Energy Model', () {
|
||
|
test('Set Values', () {
|
||
|
model.heightStart = heightStart;
|
||
|
model.heightEnd = heightEnd;
|
||
|
model.velocityStart = velocityStart;
|
||
|
model.velocityEnd = velocityEnd;
|
||
|
model.weight = weight;
|
||
|
expect(heightStart, model.heightStart);
|
||
|
expect(heightEnd, model.heightEnd);
|
||
|
expect(velocityStart, model.velocityStart);
|
||
|
expect(velocityEnd, model.velocityEnd);
|
||
|
expect(weight, model.weight);
|
||
|
});
|
||
|
test('Calculate Potential Energy', () {
|
||
|
expect(double.parse(model.calcPotentialEnergy(model.weight, model.weightForce, model.heightStart).toStringAsFixed(2)), 381118.5);
|
||
|
expect(double.parse(model.calcPotentialEnergy(model.weight, model.weightForce, model.heightEnd).toStringAsFixed(2)), 76223.70);
|
||
|
});
|
||
|
test('Calculate Potential Energy between two point in Joule', () {
|
||
|
expect(double.parse(model.calcPotentialEnergyBetweenTwoPointsInJoule(model.heightStart, model.heightEnd, model.weight).toStringAsFixed(2)), 304894.8);
|
||
|
});
|
||
|
test('Calculate Kinetic Energy', () {
|
||
|
expect(double.parse(model.calcKineticEnergy(model.weight, model.velocityStart).toStringAsFixed(2)), 0);
|
||
|
expect(double.parse(model.calcKineticEnergy(model.weight, model.velocityEnd).toStringAsFixed(2)), 621600.0);
|
||
|
});
|
||
|
test('Calculate Kinetic Energy between two points in Joule', () {
|
||
|
expect(double.parse(model.calcKineticEnergyBetweenTwoPointsInJoule(model.velocityStart, model.velocityEnd, model.weight).toStringAsFixed(2)), 621600.0);
|
||
|
});
|
||
|
test('Calculate total energy in Kilo Joule', () {
|
||
|
model.calcTotalEnergyInKiloJoule();
|
||
|
expect(double.parse(model.totalEnergy.toStringAsFixed(2)), 926.49);
|
||
|
});
|
||
|
test('Calculate amount of boiling water', () {
|
||
|
model.calcBoilingWaterAmount();
|
||
|
expect(double.parse(model.boilingWaterAmount.toStringAsFixed(2)), 2.77);
|
||
|
});
|
||
|
test('Calculate amount of annealing iron', () {
|
||
|
model.calcIronAnnealingAmount();
|
||
|
expect(double.parse(model.annealingIronAmount.toStringAsFixed(2)), 3.07);
|
||
|
|
||
|
});
|
||
|
});
|
||
|
|
||
|
}
|