Skip to content

Commit

Permalink
test: MarketPrice.copyWith
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Mar 10, 2024
1 parent d4598cb commit d2f2b6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/types/lib/src/market_price.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:convert';

import 'package:meta/meta.dart';
import 'package:types/price.dart';
import 'package:types/types.dart';
Expand Down Expand Up @@ -112,7 +110,4 @@ class MarketPrice extends PriceBase<TradeSymbol> {

/// The symbol of the trade good.
TradeSymbol get tradeSymbol => symbol;

@override
String toString() => jsonEncode(toJson());
}
22 changes: 22 additions & 0 deletions packages/types/test/src/market_price_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@ void main() {
expect(price2.hashCode, price.hashCode);
expect(json2, json);
});

test('MarketPrice.copyWith', () {
final moonLanding = DateTime.utc(1969, 7, 20, 20, 18, 04);
final price = MarketPrice(
waypointSymbol: WaypointSymbol.fromString('S-A-W'),
symbol: TradeSymbol.FUEL,
supply: SupplyLevel.ABUNDANT,
purchasePrice: 1,
sellPrice: 2,
tradeVolume: 10,
timestamp: moonLanding,
activity: ActivityLevel.WEAK,
);
// Only sellPrice is currently supported.
final price2 = price.copyWith(
sellPrice: 4,
);
expect(price2.purchasePrice, 1);
expect(price2.sellPrice, 4);
expect(price2.tradeVolume, 10);
expect(price2.activity, ActivityLevel.WEAK);
});
}

0 comments on commit d2f2b6c

Please sign in to comment.