2021-10-20 09:15:51 +03:00
|
|
|
import 'package:cherrypick/src/binding.dart';
|
2021-04-23 17:29:42 +03:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
2021-04-29 10:02:32 +03:00
|
|
|
group('Check instance.', () {
|
|
|
|
|
group('Without name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final binding = Binding<int>();
|
|
|
|
|
expect(binding.instance, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toInstance(expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toInstance(expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, true);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toInstance(expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.instance, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toInstance(expectedValue);
|
|
|
|
|
expect(binding.instance, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
group('With name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
|
|
|
|
final binding = Binding<int>().withName('expectedValue');
|
2021-04-23 17:29:42 +03:00
|
|
|
expect(binding.instance, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check key', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
|
|
|
|
|
expect(binding.key, int);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, true);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
|
|
|
|
|
expect(binding.instance, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
expect(binding.name, 'expectedValue');
|
2021-04-23 17:29:42 +03:00
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
2021-04-29 10:02:32 +03:00
|
|
|
Binding<int>().withName('expectedValue').toInstance(expectedValue);
|
2021-04-23 17:29:42 +03:00
|
|
|
expect(binding.instance, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
group('Check provide.', () {
|
|
|
|
|
group('Without name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final binding = Binding<int>();
|
|
|
|
|
expect(binding.provider, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, false);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>().toProvide(() => expectedValue);
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
group('With name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
|
|
|
|
final binding = Binding<int>().withName('expectedValue');
|
2021-04-23 17:29:42 +03:00
|
|
|
expect(binding.provider, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check key', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.key, int);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, false);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
expect(binding.name, 'expectedValue');
|
2021-04-23 17:29:42 +03:00
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue);
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
group('Check singeltone provide.', () {
|
|
|
|
|
group('Without name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final binding = Binding<int>().singeltone();
|
|
|
|
|
expect(binding.provider, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
|
|
|
|
Binding<int>().toProvide(() => expectedValue).singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
|
|
|
|
Binding<int>().toProvide(() => expectedValue).singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, true);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
|
|
|
|
Binding<int>().toProvide(() => expectedValue).singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding =
|
|
|
|
|
Binding<int>().toProvide(() => expectedValue).singeltone();
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
group('With name.', () {
|
|
|
|
|
test('Binding resolves null', () {
|
|
|
|
|
final binding = Binding<int>().withName('expectedValue').singeltone();
|
2021-04-23 17:29:42 +03:00
|
|
|
expect(binding.provider, null);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check mode', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.mode, Mode.PROVIDER_INSTANCE);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check key', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.key, int);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check singeltone', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.isSingeltone, true);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding check value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
expect(binding.name, 'expectedValue');
|
2021-04-23 17:29:42 +03:00
|
|
|
});
|
|
|
|
|
|
2021-04-29 10:02:32 +03:00
|
|
|
test('Binding resolves value', () {
|
2021-04-23 17:29:42 +03:00
|
|
|
final expectedValue = 5;
|
|
|
|
|
final binding = Binding<int>()
|
2021-04-29 10:02:32 +03:00
|
|
|
.withName('expectedValue')
|
2021-04-23 17:29:42 +03:00
|
|
|
.toProvide(() => expectedValue)
|
|
|
|
|
.singeltone();
|
|
|
|
|
expect(binding.provider, expectedValue);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|