@isTest
public class PCLLostReportByTcmControllerTest {
	@testSetup
	private static void testSetup(){
		PCLLostProduct2AssetHandlerTest.setUp();
	}
	@isTest
	private static void TestInit_Create(){
        // create Test
		Opportunity opp1 = [select id from Opportunity limit 1];
		PageReference page = 
		new PageReference('/apex/PCLLostReportPageByTcm?oppId=' 
			+opp1.Id+ '&pageStatus=Create' + + '&lostType=失单');
	    page.setRedirect(true);
	    System.Test.setCurrentPage(page);
	    Lost_cancel_report__c lcr1 = new Lost_cancel_report__c();
	    PCLLostReportByTcmController conTest = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr1));
	    conTest.init();
    }
    @isTest
	private static void TestInit_Edit(){
        EditLoad();
	}
	@isTest
	private static void TestInit_Other(){
        Lost_cancel_report__c lcr = 
		[select id 
		from Lost_cancel_report__c 
		where  LostType__c = '部分失单' limit 1];
		PageReference page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm?Id=' 
			+lcr.Id+ '&pageStatus=Edit');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    PCLLostReportByTcmController conTest2 = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
	    conTest2.init();
	    page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm?pageStatus=Create');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    conTest2 = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
	    conTest2.init();
	    page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm?oppId=' 
			+lcr.Id+ '&pageStatus=Create');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    conTest2 = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
	    conTest2.init();

	    page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm?pageStatus=Edit');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    conTest2 = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
	    conTest2.init();
	    page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    conTest2 = new PCLLostReportByTcmController(new ApexPages.StandardController(lcr));
	    conTest2.init();
	    PCLLostReportByTcmController.LostReport a =new PCLLostReportByTcmController.LostReport();
	    PCLLostReportByTcmController.LostBrand ab =new PCLLostReportByTcmController.LostBrand(0, new list<PCLLostProduct__c>());
	}
    public static PCLLostReportByTcmController EditLoad(){
        // View Edit Test
		Lost_cancel_report__c lcr2 = 
		[select id 
		from Lost_cancel_report__c 
		where  LostType__c = '失单' limit 1];
		PageReference page2 = 
		new PageReference('/apex/PCLLostReportPageByTcm?Id=' 
			+lcr2.Id + '&pageStatus=Edit');
	    page2.setRedirect(true);
	    System.Test.setCurrentPage(page2);
	    PCLLostReportByTcmController conTest2 = 
	    new PCLLostReportByTcmController(new ApexPages.StandardController(lcr2));
	    conTest2.init();
	   
        return conTest2;
        
    }
    @isTest
	private static void TestaddBrandAndProduct(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.addBrand();
        conTest2.addProduct();
        conTest2.RemoveBrandNo = 1;
        conTest2.Remove();
    }
    @isTest
	private static void TestCancel(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.cancel();
    }
    @isTest
	private static void TestSave(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.save();
    }


    @isTest
	private static void DataCheck(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.LostReport.LostReport.LostType__c = null;
        conTest2.LostReport.LostBrands[0].lostBrand.LostPrice__c = null;
        conTest2.LostReport.LostBrands[0].lostBrand.Lost_reason_main__c = null;
        conTest2.LostReport.LostBrands[0].LostProducts[0].Quantity__c =null;
        conTest2.LostReport.LostBrands[0].lostBrand.Agency__c = null;
        conTest2.DataCheck();
        conTest2.LostReport.LostBrands[0].lostBrand.Lost_By_Company__c = null;
        conTest2.DataCheck();
        conTest2.LostReport.LostBrands[0].LostProducts  = new list<PCLLostProduct__c>{
        	new PCLLostProduct__c(Quantity__c = 0) };
         conTest2.DataCheck();
    }
    @isTest
	private static void TestEdit2(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.edit2();
    }

    @isTest
	private static void TestSubmit(){
        PCLLostReportByTcmController conTest2 = EditLoad();
        conTest2.submit();
    }




}