Whoops, add the demo type library and the trivial test also
t0m [Thu, 28 May 2009 00:34:33 +0000 (01:34 +0100)]
t/08_types_in_model.t [new file with mode: 0644]
t/lib/DemoTypeLibrary.pm [new file with mode: 0644]

diff --git a/t/08_types_in_model.t b/t/08_types_in_model.t
new file mode 100644 (file)
index 0000000..1b3aadb
--- /dev/null
@@ -0,0 +1,20 @@
+use strict;
+use warnings;
+
+use FindBin qw/$Bin/;
+use lib "$Bin/lib";
+
+use Test::More tests => 6;
+use Test::Exception;
+
+use SomeModelClass;
+my $i = SomeModelClass->new;
+
+throws_ok { $i->say_hello(); } qr/Validation failed/;
+throws_ok { $i->say_hello({}); } qr/Validation failed/;
+throws_ok { $i->say_hello({name => 'Fred'}); } qr/Validation failed/;
+my $r;
+lives_ok { $r = $i->say_hello({type => 'say_hello', name => 'Fred'}); };
+ok $r;
+is_deeply($r, { type => 'say_hello_response', body => "Hello Fred" });
+
diff --git a/t/lib/DemoTypeLibrary.pm b/t/lib/DemoTypeLibrary.pm
new file mode 100644 (file)
index 0000000..3019fc5
--- /dev/null
@@ -0,0 +1,19 @@
+package DemoTypeLibrary;
+
+use MooseX::Types 
+    -declare => [qw(
+        MessageDocument
+    )];
+
+use MooseX::Types::Moose qw/Str/;
+use MooseX::Types::Structured qw/Dict/;
+
+subtype MessageDocument,
+    as Dict[
+        name => Str,
+        type => Str,
+    ];
+
+
+1;
+