/*
 Babylon Service - lookup words in www.babylon.com
 Copyright © 2006 Nir Soffer

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#import <SenTestingKit/SenTestingKit.h>
#import "BabylonService.h"

@interface BabylonServiceTests : SenTestCase 
{
    BabylonService *service;
}
@end

@implementation BabylonServiceTests

- (void)setUp
{
    service = [[BabylonService alloc] init];
}

- (void)tearDown
{
    [service release];
}

#pragma Creating URLs

- (void)testURLForTerm
{
    STAssertEqualObjects([[service urlForTerm:@"needle" 
                                     language:nil] absoluteString], 
                         @"http://www.babylon.com/definition/needle", 
                         @"should create definition url for needle");
}

- (void)testURLForTermHebrew
{
    STAssertEqualObjects([[service urlForTerm:@"needle" 
                                     language:@"Hebrew"] absoluteString], 
                         @"http://www.babylon.com/definition/needle/Hebrew", 
                         @"should create hebrew definition url for needle");
}

- (void)testTrimWhitespace
{
    STAssertEqualObjects([[service urlForTerm:@"   needle   " 
                                     language:nil] absoluteString], 
                         @"http://www.babylon.com/definition/needle", 
                         @"should trim whitespace");
}

- (void)testEscapePathComponentCharacters
{
    STAssertEqualObjects([[service urlForTerm:@"/;=?" 
                                     language:nil] absoluteString], 
                         @"http://www.babylon.com/definition/%2F%3B%3D%3F", 
                         @"should escape reserved path component characters");
}

@end
