buli
2022-04-08 b6f2c55d21463def425048aba48bed273156e9a9
force-app/main/default/classes/TydelikeConControllerTest.cls
@@ -1,236 +1,47 @@
@isTest
private class TydelikeConControllerTest {
public class TydelikeConControllerTest {
    static testMethod void testMethod1() {
        TydelikeAccount__c acc1 = new TydelikeAccount__c();
            acc1.name = '**';
            acc1.OwnerId = UserInfo.getUserId();
            acc1.TyCity__c = '北京';
            acc1.OfSkrap__c = false;
            acc1.TyAddress__c = '11111';
            acc1.TyPostCode__c = '123456';
        insert acc1;
        Account acctest = TestDataUtility.CreateAccounts(1)[0];
        acctest.ProductSegment__c = 'BS';
      update acctest;
        TydelikeContact__c tycotest = new TydelikeContact__c();
        tycotest.Name = 'test';
        tycotest.TyAddress__c = 'test';
        tycotest.TyFaxD__c = 'test';
        tycotest.TyPhoneD__c = '13566667777';
        tycotest.TyPostcode__c = '5000000';
        tycotest.EnglishAddress__c = 'test';
        tycotest.ContactEnglishName__c = 'test';
        insert tycotest;
        TydelikeAccount__c tyaccount = new TydelikeAccount__c();
        TydelikeContact__c tycon1 = new TydelikeContact__c();
           tycon1.name = '*';
           tycon1.OfSkrap__c = false;
           tycon1.TydelikeAccount__c = acc1.Id;
           tycon1.TyAddress__c = '11111';
           tycon1.TyFaxD__c = '1111';
           tycon1.TyPhoneD__c = '15555555555';
           tycon1.TyPostcode__c = '111111';
            tycon1.EnglishAddress__c = '111111';
            tycon1.ContactEnglishName__c = '111111';
        insert tycon1;
        System.debug(tycon1);
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
        Account buyer = new Account(
            Name = '*',
            FacilityName__c = 'buyer',
            PostCode__c = '123456',
            RecordTypeId = rectDealer[0].Id,
            ProductSegment__c = 'BS'
        );
        insert buyer;
        System.debug(buyer);
        /*Account accBS = new Account(
            Name = '12343',
            RecordTypeId = rectBS[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName_D__c = '010',
            FacilityNameD__c = '011',
            DepartmentNameD__c = '001',
            Province__c = '北京',
            CityD__c = 'beijing',
            Address1D__c = '7hao',
            UserType__c = 'OEM客户',
            MarketVerticalsD__c = 'Education',
            IndustryBD__c = 'Education',
            UseD__c = 'Education',
            DivisionName__c = '010',
            FacilityName__c = '011',
            DepartmentName__c = '001',
            City__c = 'beijing',
            Address1__c = '7hao',
            MarketVerticals__c = 'Education',
            IndustryB__c = 'Education',
            Use__c = 'Education',
            ProductSegment__c = 'BS'
        );
        insert accBS;
        System.debug(accBS);*/
        PageReference page = new PageReference('/apex/TydelikeCon?accName=' + buyer.Name + '&tyacId=' + acc1.Id + '&tycoId=' + tycon1.Id);
        System.Test.setCurrentPage(page);
        TydelikeConController controller = new TydelikeConController();
        controller.init();
        controller.save();
        String url = ApexPages.currentPage().getParameters().put('accName',acctest.Name);
        url = ApexPages.currentPage().getParameters().put('tycoId',tycotest.Id);
        url = ApexPages.currentPage().getParameters().put('tyacId',tyaccount.Id);
       Test.startTest();
        TydelikeConController scc = new TydelikeConController();
        scc.acc = acctest;
        scc.tya = tyaccount;
        scc.init();
        scc.save();
        acctest.ProductSegment__c = 'IE';
        update acctest;
        scc.init();
        acctest.ProductSegment__c = 'NDT';
        update acctest;
        scc.init();
        acctest.ProductSegment__c = 'ANI';
        update acctest;
        scc.init();
        acctest.ProductSegment__c = 'RVI';
        update acctest;
        scc.init();
        Test.stopTest();
    }
     static testMethod void testMethod2() {
        TydelikeAccount__c acc1 = new TydelikeAccount__c();
            acc1.name = '**';
            acc1.OwnerId = UserInfo.getUserId();
            acc1.TyCity__c = '北京';
            acc1.OfSkrap__c = false;
            acc1.TyAddress__c = '11111';
            acc1.TyPostCode__c = '123456';
        insert acc1;
        TydelikeContact__c tycon1 = new TydelikeContact__c();
            tycon1.name = '*';
            tycon1.OfSkrap__c = false;
            tycon1.TydelikeAccount__c = acc1.Id;
            tycon1.TyAddress__c = '11111';
            tycon1.TyFaxD__c = '1111';
            tycon1.TyPhoneD__c = '15555555555';
            tycon1.TyPostcode__c = '111111';
        insert tycon1;
        System.debug(tycon1);
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
        Account buyer = new Account(
            Name = '*',
            FacilityName__c = 'buyer',
            PostCode__c = '123456',
            RecordTypeId = rectDealer[0].Id,
            ProductSegment__c = 'IE'
        );
        insert buyer;
        System.debug(buyer);
        PageReference page = new PageReference('/apex/TydelikeCon?accName=' + buyer.Name + '&tyacId=' + acc1.Id + '&tycoId=' + tycon1.Id);
        System.Test.setCurrentPage(page);
        TydelikeConController controller = new TydelikeConController();
        controller.init();
        controller.save();
    }
     static testMethod void testMethod3() {
        TydelikeAccount__c acc1 = new TydelikeAccount__c();
            acc1.name = '**';
            acc1.OwnerId = UserInfo.getUserId();
            acc1.TyCity__c = '北京';
            acc1.OfSkrap__c = false;
            acc1.TyAddress__c = '11111';
            acc1.TyPostCode__c = '123456';
        insert acc1;
        TydelikeContact__c tycon1 = new TydelikeContact__c();
            tycon1.name = '*';
            tycon1.OfSkrap__c = false;
            tycon1.TydelikeAccount__c = acc1.Id;
            tycon1.TyAddress__c = '11111';
            tycon1.TyFaxD__c = '1111';
            tycon1.TyPhoneD__c = '15555555555';
            tycon1.TyPostcode__c = '111111';
        insert tycon1;
        System.debug(tycon1);
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
        Account buyer = new Account(
            Name = '*',
            FacilityName__c = 'buyer',
            PostCode__c = '123456',
            RecordTypeId = rectDealer[0].Id,
            ProductSegment__c = 'NDT'
        );
        insert buyer;
        System.debug(buyer);
        PageReference page = new PageReference('/apex/TydelikeCon?accName=' + buyer.Name + '&tyacId=' + acc1.Id + '&tycoId=' + tycon1.Id);
        System.Test.setCurrentPage(page);
        TydelikeConController controller = new TydelikeConController();
        controller.init();
        controller.save();
    }
     static testMethod void testMethod4() {
        TydelikeAccount__c acc1 = new TydelikeAccount__c();
            acc1.name = '**';
            acc1.OwnerId = UserInfo.getUserId();
            acc1.TyCity__c = '北京';
            acc1.OfSkrap__c = false;
            acc1.TyAddress__c = '11111';
            acc1.TyPostCode__c = '123456';
        insert acc1;
        TydelikeContact__c tycon1 = new TydelikeContact__c();
            tycon1.name = '*';
            tycon1.OfSkrap__c = false;
            tycon1.TydelikeAccount__c = acc1.Id;
            tycon1.TyAddress__c = '11111';
            tycon1.TyFaxD__c = '1111';
            tycon1.TyPhoneD__c = '15555555555';
            tycon1.TyPostcode__c = '111111';
        insert tycon1;
        System.debug(tycon1);
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
        Account buyer = new Account(
            Name = '*',
            FacilityName__c = 'buyer',
            PostCode__c = '123456',
            RecordTypeId = rectDealer[0].Id,
            ProductSegment__c = 'ANI'
        );
        insert buyer;
        System.debug(buyer);
        PageReference page = new PageReference('/apex/TydelikeCon?accName=' + buyer.Name + '&tyacId=' + acc1.Id + '&tycoId=' + tycon1.Id);
        System.Test.setCurrentPage(page);
        TydelikeConController controller = new TydelikeConController();
        controller.init();
        controller.save();
    }
     static testMethod void testMethod5() {
        TydelikeAccount__c acc1 = new TydelikeAccount__c();
            acc1.name = '**';
            acc1.OwnerId = UserInfo.getUserId();
            acc1.TyCity__c = '北京';
            acc1.OfSkrap__c = false;
            acc1.TyAddress__c = '11111';
            acc1.TyPostCode__c = '123456';
        insert acc1;
        TydelikeContact__c tycon1 = new TydelikeContact__c();
            tycon1.name = '*';
            tycon1.OfSkrap__c = false;
            tycon1.TydelikeAccount__c = acc1.Id;
            tycon1.TyAddress__c = '11111';
            tycon1.TyFaxD__c = '1111';
            tycon1.TyPhoneD__c = '15555555555';
            tycon1.TyPostcode__c = '111111';
        insert tycon1;
        System.debug(tycon1);
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectBS = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer BS'];
        Account buyer = new Account(
            Name = '*',
            FacilityName__c = 'buyer',
            PostCode__c = '123456',
            RecordTypeId = rectDealer[0].Id,
            ProductSegment__c = 'RVI'
        );
        insert buyer;
        System.debug(buyer);
        PageReference page = new PageReference('/apex/TydelikeCon?accName=' + buyer.Name + '&tyacId=' + acc1.Id + '&tycoId=' + tycon1.Id);
        System.Test.setCurrentPage(page);
        TydelikeConController controller = new TydelikeConController();
        controller.init();
        controller.save();
    }
}