annotate _test/Test/Resources/Format.pm @ 42:4ff27cd051e3

updated ORM schema model
author Sergey
date Thu, 07 Jan 2010 15:34:42 +0300
parents 818c74b038ae
children 16ada169ca75
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
1 package Test::Resources::Format;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
2 use strict;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
3 use warnings;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
4
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
5 use base qw(IMPL::Test::Unit);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
6 use IMPL::Test qw(test failed);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
7 use IMPL::Resources::Format qw(FormatMessage);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
8
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
9 __PACKAGE__->PassThroughArgs;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
10
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
11 {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
12 package Args;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
13 use base qw(IMPL::Object);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
14
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
15 sub foo {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
16 return { name => 'Args::foo', value => 'some value'}
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
17 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
18 }
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
19
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
20 test FormatMessage => sub {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
21 my $format = 'This is a %name% message. %args.foo.name% has %args.foo.value% and %some.unknown.param%';
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
22
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
23 my $args = {
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
24 name => 'Test',
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
25 args => new Args()
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
26 };
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
27
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
28 my $result = FormatMessage($format,$args);
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
29 my $expected = 'This is a Test message. Args::foo has some value and [some.unknown.param]';
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
30
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
31 failed
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
32 "Format message returned unexpected results",
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
33 "Expected: $expected",
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
34 "Recieved: $result"
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
35 unless $result eq $expected;
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
36 };
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
37
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
38
818c74b038ae DOM Schema + tests
Sergey
parents:
diff changeset
39 1;