@isTest
private class SearchSetProductControllerTest {
	
	@isTest static void test_method_one() {
		Id pricebookId = Test.getStandardPricebookId();

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

        Product2 product1 = new Product2();
        product1.Name = 'product1';
        product1.ProductCode = 'product1';
        product1.Product_ECCode__c = 'product1';
        product1.ProductModels__c = true;
        product1.ProductStatus__c = '1';
        insert product1;

        PricebookEntry standardPrice1 = new PricebookEntry(
            Pricebook2Id = pricebookId,
            Product2Id = product1.Id,
            UnitPrice = 0,
            IsActive = true
        );
        insert standardPrice1;

        PricebookEntry entry1 = new PricebookEntry(Pricebook2Id = pricebook.Id, Product2Id = product1.Id);
        entry1.UnitPrice = 0;
        entry1.IsActive = true;
        entry1.UseStandardPrice = false;
        insert entry1;

        Product_Search__c ps = new Product_Search__c(Product__c = product1.Id);

        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        Account user = new Account(
            Name = '*',
            FacilityName__c = 'user',
            PostCode__c = '123456',
            RecordTypeId = rectIE[0].Id
        );
        insert user;

        Opportunity opp = new Opportunity(
            Name = 'test opp',
            AccountId = user.Id,
            StageName = 'Prospect Created',
            CurrencyIsoCode = 'CNY',
            ProductSegment__c = 'IE',
            CloseDate = Date.today(),
            NewInquiryDate__c = Date.today().addDays(-2),
            ExpectedOrderDate__c = Date.today().addDays(2),
            TradeType__c = 'Taxation',
            SalesChannel__c = 'direct',
            Machine_Parts__c = 'Machine',
            Pricebook2Id = pricebook.Id
        );
        insert opp;
         Quote quo = new Quote(
            Name = 'quo',
            OpportunityId = opp.Id,
            SetName1__c = 'setname01',
            SetQty1__c = 1
        );
        insert quo;
        productSet__c proSet1 = new productSet__c();
        proSet1.Code__c = 'IXP-7P2';
        proSet1.Name = 'IXP-7P2';
        proSet1.IsValid__c = true;
        proSet1.Name = 'IXP-7P2';
        insert proSet1;

        productSet__c proSet2 = new productSet__c();
        proSet2.Code__c = 'IXP-7P1SC';
        proSet2.Name = 'IXP-7P1SC';
        proSet2.IsValid__c = true;
        proSet2.Name = 'IXP-7P1SC';
        insert proSet2;
        productSet__c proSet3 = new productSet__c();
        proSet3.Code__c = 'IXSP-T7LED';
        proSet3.Name = 'IXSP-T7LED';
        proSet3.IsValid__c = true;
        proSet3.Name = 'IXSP-T7LED';
        insert proSet3;
        //PageReference page = new PageReference('/apex/SearchProduct?oppId=' + opp.Id + '&val=product1');
        //PageReference page = new PageReference('/apex/SearchSetProduct?Id=' + quo.Id );
        PageReference page = new PageReference('/apex/SearchSetProduct?gainQuoteSetNameAndSetQty=IX73双层手动%2C2%2C25%3BIX73双层编码机架%2C2%2C25%3BIX73双层手动%2C2%2C25%3BIX73双层编码机架%2C2%2C25');
        //PageReference page = new PageReference('/apex/SearchSetProduct??gainQuoteSetNameAndSetQty=');
        
        System.Test.setCurrentPage(page);
        SearchSetProductController controller = new SearchSetProductController();
        
        controller.init();
        controller.SearchName = 'IXSP-T7LED';
        controller.SearchCode = 'IXSP-T7LED';
        controller.serContact();
        controller.SelectDone();
	}
	
}