-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstant_resolve.cpp
More file actions
66 lines (48 loc) · 1.76 KB
/
Copy pathconstant_resolve.cpp
File metadata and controls
66 lines (48 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#define CATCH_CONFIG_ENABLE_BENCHMARKING
#include <catch2/catch.hpp>
#include <mosure/inversify.hpp>
#include "mock/symbols.hpp"
namespace inversify = mosure::inversify;
SCENARIO("container resolves constant values", "[resolve]") {
GIVEN("A container with constant binding") {
inversify::Container<
symbols::foo
> container;
container.bind<symbols::foo>().toConstantValue(10);
WHEN("the dependency is resolved") {
auto result = container.get<symbols::foo>();
THEN("the correct value is returned") {
REQUIRE(result == 10);
}
}
WHEN("the binding is redefined") {
container.bind<symbols::foo>().toConstantValue(20);
WHEN("the dependency is resolved") {
auto result = container.get<symbols::foo>();
THEN("the updated value is returned") {
REQUIRE(result == 20);
}
}
}
}
GIVEN("A container with constant bindings of the same type") {
inversify::Container<
symbols::foo,
symbols::foo2
> container;
container.bind<symbols::foo>().toConstantValue(10);
container.bind<symbols::foo2>().toConstantValue(20);
WHEN("the foo is resolved") {
auto result = container.get<symbols::foo>();
THEN("the correct value is returned") {
REQUIRE(result == 10);
}
}
WHEN("the foo2 is resolved") {
auto result = container.get<symbols::foo2>();
THEN("the correct value is returned") {
REQUIRE(result == 20);
}
}
}
}