# # HotdogVendor_Test.pl: HotdogVendor.pm Test (Test::Class, unit testing) # package HotdogVendorTest; use base qw(Test::Class); use Test::More; use HotdogVendor; # Test that name is saved on new vendor creation sub test_name : Test(1) { my $name = "Thomas"; my $hotdogVendor = HotdogVendor->new($name, 100); is ($hotdogVendor->name, $name, 'name saved'); } # Test product franks is saved and used works sub test_franks : Test(2) { my $how_many = 100; my $hotdogVendor = HotdogVendor->new('Chris', $how_many); is ($hotdogVendor->has_franks, $how_many, 'franks amount saved'); $hotdogVendor->use_franks(60); is ($hotdogVendor->has_franks, 40, '100 - 60 franks is 40 franks'); } # Test product buns is saved and used works sub test_buns : Test(2) { my $how_many = 100; my $hotdogVendor = HotdogVendor->new('Chris', $how_many); is ($hotdogVendor->has_buns, $how_many, 'buns amount saved'); $hotdogVendor->use_buns(60); is ($hotdogVendor->has_buns, 40, '100 - 60 buns is 40 buns'); } # Test product mustard is saved and used works sub test_mustard : Test(2) { my $how_many = 100; my $hotdogVendor = HotdogVendor->new('Chris', $how_many); is ($hotdogVendor->has_mustard, $how_many, 'mustard amount saved'); $hotdogVendor->use_mustard(60); is ($hotdogVendor->has_mustard, 40, '100 - 60 mustard is 40 mustard'); } # Test product mustard is saved and used works sub test_kraut : Test(2) { my $how_many = 100; my $hotdogVendor = HotdogVendor->new('Chris', $how_many); is ($hotdogVendor->has_kraut, $how_many, 'kraut amount saved'); $hotdogVendor->use_kraut(60); is ($hotdogVendor->has_kraut, 40, '100 - 60 kraut is 40 kraut'); } 1;