cpd_2022_energy/test/EnergyModelProvider_test.dart

63 lines
1.8 KiB
Dart

import 'package:energy/model/EnergyModelProvider.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('EnergyModelProviderTest1', () {
final provider = EnergyModelProvider();
test('Tests calculateEnergyInJoule', () {
provider.calculateEnergyInJoule('100', '500');
expect(provider.energyInJoule, 2500.0);
});
test('Tests calculateEnergyPotential', () {
provider.calculateEnergyPotential('10', '50');
expect(provider.potentialEnergy, 4905.0);
});
test('Tests calculateEnergyPotential', () {
provider.calculateEnergyKinetic('10', '50');
expect(provider.kineticEnergy, 12500.0);
});
test('Tests calculateEnergyPotential', () {
provider.calculateLiterToHeatWater();
expect(provider.literWaterToHeat, 0.05202355332376853);
});
test('Tests calculateKgToHeatIron', () {
provider.calculateKgToHeatIron();
expect(provider.kilogrammIronToHeat, 0.055642583120204606);
});
});
group('EnergyProviderTest2', () {
final provider = EnergyModelProvider();
test('Tests calculateEnergyInJoule', () {
provider.calculateEnergyInJoule('5000', '180');
expect(provider.energyInJoule, 6.48);
});
test('Tests calculateEnergyPotential', () {
provider.calculateEnergyPotential('5000', '60');
expect(provider.potentialEnergy, 2943000.0);
});
test('Tests calculateEnergyPotential', () {
provider.calculateEnergyKinetic('2000', '60');
expect(provider.kineticEnergy, 3600000.0);
});
test('Tests calculateEnergyPotential', () {
provider.calculateLiterToHeatWater();
expect(provider.literWaterToHeat, 19.557030129124822);
});
test('Tests calculateKgToHeatIron', () {
provider.calculateKgToHeatIron();
expect(provider.kilogrammIronToHeat, 20.91751918158568);
});
});
}