@isTest
public with sharing class OrderShippingNotificationControllerTest {

    static testMethod void myTest1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account accIE = new Account(
            Name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c='Customer IE',
            FacilityName__c='abc',
            PostCode__c='000000'
        );
        insert accIE; 
        
        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE'
        );
        insert pricebook;
         
        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
       
        Opportunity opp = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Prospect Created',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            ExpectedDeliveryDate__c = Date.today(),
            SalesChannel__c = 'direct'
        );
        insert opp;

        Order odr = new Order(
            Name = '',
            Status = 'Draft',
            AccountId = accIE.Id,
            ApproveStatus__c = 'Draft',
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ShippingNotes__c = '',
            ShippingRecieverEmailAdr__c = ''
        );
        insert odr;
        
         //发货提醒输入画面
        PageReference page = new PageReference('/apex/OrderShippingNotification?raid=' + odr.Id );
        System.Test.setCurrentPage(page);
        
        OrderShippingNotificationController controller = new OrderShippingNotificationController();
        

        //取得订单
        Order odr1 = [select Id, Name,ContractCode__c, ShippingNotes__c,ShippingRecieverEmailAdr__c, OppExpectedDeliveryDate__c from Order where Id = :odr.Id];

        //初始化
        controller.init();
        System.assertEquals('期望发货日期:' + odr1.OppExpectedDeliveryDate__c, controller.ra.ShippingNotes__c);
        System.assertEquals(odr1.ShippingRecieverEmailAdr__c, controller.ra.ShippingRecieverEmailAdr__c);
        
        
        //发送按钮
        controller.ra.ShippingNotes__c = 'test1';

        //保存后
        controller.saveBtn();



    }



}