This commit is contained in:
2021-09-11 08:27:27 +06:30
parent 7e9ea1b867
commit a4d3777e8a
55 changed files with 929 additions and 382 deletions

View File

@@ -1,33 +0,0 @@
import 'package:fcs/domain/entities/cargo_type.dart';
import 'package:fcs/domain/entities/carton.dart';
import 'package:fcs/domain/entities/discount_by_weight.dart';
import 'package:fcs/domain/entities/rate.dart';
import 'package:test/test.dart';
@TestOn('vm')
void main() {
var rate = Rate();
rate.discountByWeights = [
DiscountByWeight(weight: 25, discount: 0.25),
DiscountByWeight(weight: 50, discount: 0.5),
];
rate.volumetricRatio = 166.36;
rate.diffDiscountWeight = 5;
rate.diffWeightRate = 1.5;
test('Calculate carton price 1', () {
var ct = CargoType(name: "General", weight: 10, rate: 6);
var carton = Carton(cargoTypes: [ct], length: 15, width: 15, height: 15);
expect(carton.calAmount(rate), equals(67.50));
});
test('Calculate carton price 2', () {
var ct = CargoType(name: "General", weight: 10, rate: 6);
var carton = Carton(cargoTypes: [ct], length: 10, width: 10, height: 10);
expect(carton.calAmount(rate), equals(60));
});
test('Calculate carton price 3', () {
var ct = CargoType(name: "General", weight: 10, rate: 6);
var carton = Carton(cargoTypes: [ct], length: 15, width: 15, height: 10);
expect(carton.calAmount(rate), equals(60));
});
}

30
test/widget_test.dart Normal file
View File

@@ -0,0 +1,30 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
// utility that Flutter provides. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:fcs/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
});
}