@isTest
private class IENewOpportunityControllerTest {

	@isTest static void test_method_one() {
        IENewOpportunityController.asd();
		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 = '123456',
            compo_Acc__c = 'COMPO客户'
        );
        insert accIE;

        Contact con = new Contact();
        con.LastName = 'test';
        con.AccountId = accIE.Id;
        con.MobilePhone = 'MobilePhoneD__c';
        con.OtherPhone = 'OtherPhoneD__c';
        con.Fax = 'FaxD__c';
        con.Email = 'EmailD__c@test.com';
        con.Phone = 'PhoneD__c';
        con.Title = 'TitleD__c';
        con.Address1__c = 'Address1D__c';
        con.Address2__c = 'Address2D__c';
        con.Address3__c = 'Address3D__c';
        con.Postcode__c = '100111';
        con.ContactStatus__c = 'ContactStatusD__c';
        con.CancelReason__c = 'CancelReasonD__c';
        con.StatusD__c = 'Pass';

        insert con;

        PriceBook2 pricebook =new PriceBook2(
            Name = 'IE',
            ProductSegment__c = 'IE',
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            MachineParts__c = 'Machine'
        );
        insert pricebook;

        List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
        // 有预定下单日
        Opportunity opp1 = new Opportunity(
            Name = 'test opp',
            AccountId = accIE.Id,
            RecordTypeId = rectOpp[0].Id,
            OwnerId = UserInfo.getUserId(),
            StageName = 'Phase3',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            SalesChannel__c = 'direct',
            TradeType__c = 'Taxation'
        );
        insert opp1;

        PageReference page = new PageReference('/apex/NewOpportunity?accid=' + accIE.Id + '&conId=' + con.Id);
        System.Test.setCurrentPage(page);
        IENewOpportunityController controller = new IENewOpportunityController();

        controller.init();

        controller.opp.Name = 'test opp 001';
        controller.opp.TradeType__c = 'Taxation';
        controller.opp.LeadSource = 'Others';
        controller.opp.SalesChannel__c = 'direct';
        controller.opp.Have_Computer__c = true;
        controller.opp.Association_Opportunity__c = opp1.Id;
        controller.saveBtn();
        //system.assertEquals(null,ApexPages.getMessages()[0].getDetail());

        controller.saveBtnYes();

        controller.saveBtnNo();
	}

}