source: branches/features/purchaseOrders/test/unit/PurchaseOrderNumberTests.groovy @ 954

Last change on this file since 954 was 894, checked in by gav, 14 years ago

Comments to PurchaseOrderNumberTests and ! PurchaseOrderServiceTests?.

File size: 1.3 KB
Line 
1import static org.junit.Assert.assertThat
2import static org.hamcrest.CoreMatchers.equalTo
3import grails.test.GrailsUnitTestCase
4
5/**
6 * Unit tests for PurchaseOrderNumber domain class.
7 */
8class PurchaseOrderNumberTests extends GrailsUnitTestCase {
9    protected void setUp() {
10        super.setUp()
11        mockDomain(PurchaseOrder)
12        mockDomain(PurchaseOrderNumber)
13    }
14
15    protected void tearDown() {
16        super.tearDown()
17    }
18
19    void testGetDescriptionForNewPurchaseOrder() {
20        createTenPurchaseOrderNumbers()
21        def pon = PurchaseOrderNumber.get(1)
22
23        assertThat pon.description, equalTo("P1000 - new")
24    }
25
26    void testGetDescriptionForExistingPurchaseOrder() {
27        def pon = new PurchaseOrderNumber(value:"P1234").save(failOnError:true)
28        def supplier = new Supplier(name:"Supplier Name",supplierType:new SupplierType())
29        def po = new PurchaseOrder(purchaseOrderNumber:pon, supplier:supplier)
30        pon.purchaseOrder = po
31        pon.save(failOnError:true)
32        po.save(failOnError:true)
33
34        assertThat pon.description, equalTo("P1234 for Supplier Name")
35    }
36
37    private createTenPurchaseOrderNumbers() {
38        for (int i = 1000; i < 1010; i++) {
39            new PurchaseOrderNumber(value: "P${i}").save(failOnError: true)
40        }
41    }
42
43}
Note: See TracBrowser for help on using the repository browser.