//
//  UnitContainerTests.m
//  MealBuilder
//
//  Created by Phil Horowitz on 2/23/13.
//  Copyright (c) 2013 Phil Horowitz. All rights reserved.
//

#import "UnitContainerTests.h"
#import "Measurements.h"

@implementation UnitContainerTests

-(void) testToBaseUnit{
    Unit *fl = [[FluidOunce alloc] initWithAmount:100];
    Unit *controlMl = [((Unit *)[fl copy]) toBaseUnit];
    UnitContainer *testContainer = [[UnitContainer alloc] initWithUnit:fl];
    [testContainer toBaseUnit];
    STAssertEqualsWithAccuracy(testContainer.unit.amount, controlMl.amount, 0.1, @"toBaseUnit should convert the unit to its base");
}

-(void) testToCompatibleUnitConverts{
    Unit *ml = [[Milliliter alloc] initWithAmount: 4572];
    UnitContainer *container = [[UnitContainer alloc] initWithUnit:ml];
    Unit *compat = [[FluidOunce alloc] init];
    Unit *control = [[FluidOunce alloc] initFromCompatibleUnit:ml];
    
    [container toCompatibleUnit:compat];
    STAssertEqualsWithAccuracy(container.unit.amount, control.amount, 0.1, @"toCompatibleUnit should convert the unit");
}

@end
