49
|
1 package Test::Resources::Format;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use base qw(IMPL::Test::Unit);
|
|
6 use IMPL::Test qw(test failed);
|
|
7 use IMPL::Resources::Format qw(FormatMessage);
|
|
8
|
|
9 __PACKAGE__->PassThroughArgs;
|
|
10
|
|
11 {
|
|
12 package Args;
|
|
13 use base qw(IMPL::Object);
|
|
14
|
|
15 sub foo {
|
|
16 return { name => 'Args::foo', value => 'some value'}
|
|
17 }
|
|
18 }
|
|
19
|
|
20 test FormatMessage => sub {
|
|
21 my $format = 'This is a %name% message. %args.foo.name% has %args.foo.value% and %some.unknown.param%';
|
|
22
|
|
23 my $args = {
|
|
24 name => 'Test',
|
|
25 args => new Args()
|
|
26 };
|
|
27
|
|
28 my $result = FormatMessage($format,$args);
|
|
29 my $expected = 'This is a Test message. Args::foo has some value and [some.unknown.param]';
|
|
30
|
|
31 failed
|
|
32 "Format message returned unexpected results",
|
|
33 "Expected: $expected",
|
|
34 "Recieved: $result"
|
|
35 unless $result eq $expected;
|
|
36 };
|
|
37
|
|
38
|
|
39 1;
|