/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an org are executed whenever Apex code is deployed
 * to a production org to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production org. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the org size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class PreProductStorageHandelerTest {

    @isTest
    static void myUnitTest() {
        // TO DO: implement unit test
        String recordEntailCompoId = [SELECT Id FROM RecordType where name ='整机' and DeveloperName ='EntailCompo'].Id;
        String recordConsumablesId = [SELECT Id FROM RecordType where name ='耗材' and DeveloperName ='Consumables'].Id;
        Product2 pro5 = new Product2(Name='name05',IsActive=true,Family='SP',
        Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
        Fixture_Model_No_T__c = 'n05',
        Asset_Model_No__c = 'SNTest123xx',
        ProductCode_Ext__c='pc05',Manual_Entry__c=false);
        insert pro5;

        PreProduct_Storage__c  storage1 = new PreProduct_Storage__c();
        storage1.Name = '*';
        storage1.Storage_Number__c=100;
        storage1.Field1__c = pro5.Id;
        storage1.ifValid__c=true;
        storage1.Department__c='1.华北';
        storage1.Province__c = '安徽';
        storage1.RecordTypeId =recordEntailCompoId;
        insert storage1;

        PreProduct_Storage__c  storage2 = new PreProduct_Storage__c();
        storage2.Name = '*';
        storage2.Storage_Number__c=100;
        storage2.Field1__c = pro5.Id;
        storage2.ifValid__c=true;
        storage2.Department__c='1.华北';
        storage2.Province__c = '吉林';
        storage2.RecordTypeId =recordConsumablesId;
        insert storage2;

        storage1.Province__c='上海';
        storage1.Name = 'xxx123';
        UPDATE storage1;

        storage2.Province__c='黑龙江';
        storage2.Name = 'test123';
        UPDATE storage2;

        PreProduct_StorageAdjust__c   adjust1 = new PreProduct_StorageAdjust__c();
        adjust1.PreProduct_Storage__c = storage1.Id;
        adjust1.PreProduct_StorageGive__c = storage2.Id;
        adjust1.Status__c = '草案中';
        adjust1.Quantity__c=10;
        INSERT adjust1;

        PreProduct_StorageAdjust__c   adjust2 = new PreProduct_StorageAdjust__c();
        adjust2.PreProduct_Storage__c = storage2.Id;
        adjust2.PreProduct_StorageGive__c = storage1.Id;
        adjust2.Status__c = '草案中';
        adjust2.Quantity__c=10;
        INSERT adjust2;

        adjust2.Status__c ='申请中';
        UPDATE adjust2;
        adjust1.Status__c ='申请中';
        UPDATE adjust1;

        adjust1.Status__c ='批准';
        UPDATE adjust1;
        adjust2.Status__c = '驳回';
        UPDATE adjust2;
        adjust2.Status__c ='申请中';
        UPDATE adjust2;
        adjust2.Status__c = '审批撤回';
        UPDATE adjust2;




    }
}