예제 #1
0
        public async Task CreateNewSpecification()
        {
            short  theEmpID     = 991; //Ben Johnson
            string theExtRevId  = "A";
            int    samplePlanId = 1;
            string descPrefix   = " - This is a test. Rev: ";

            var thePreAddSpecList = await SpecService.GetAllHydratedSpecs();

            var calcNewMaxSpecId = thePreAddSpecList.Max(i => i.Id) + 1;

            var theBaselineSpecModel = CreateBaselineSpecModel(theExtRevId, descPrefix, theEmpID, samplePlanId, 0, 0);
            var theCreatedSpecId     = await SpecService.CreateNewSpec(theBaselineSpecModel);

            var theCreatedSpecModel = await SpecService.GetHydratedCurrentRevForSpec(theCreatedSpecId);

            ///set test values
            theBaselineSpecModel.Id = calcNewMaxSpecId;
            theBaselineSpecModel.SpecRevModels.ElementAt(0).DateCreated = DateTime.Now.Date;
            theBaselineSpecModel.SpecRevModels.ElementAt(0).TimeCreated = DateTime.Now.TimeOfDay;
            theBaselineSpecModel.SpecRevModels.ElementAt(0).SpecId      = calcNewMaxSpecId;
            theBaselineSpecModel.SpecRevModels.ElementAt(0).InternalRev = 10;
            theBaselineSpecModel.SpecRevModels.ElementAt(0).Description = DateTime.Now.Date.ToString("yyyy/MM/dd") + descPrefix + theExtRevId;

            //total spec count increased by 1

            Validate.ValidateModelCompleteness(theBaselineSpecModel, theCreatedSpecModel, new List <Object>()
            {
                "SpecRevModels"
            });
            Validate.ValidateModelCompleteness(theBaselineSpecModel.SpecRevModels.ElementAt(0), theCreatedSpecModel.SpecRevModels.ElementAt(0),
                                               new List <Object>()
            {
                "TimeCreated", "SubLevels"
            });                                                     // excluded TimeModified because there is a variation in (milli)seconds we can't account for
            //Warning! Testing against DateModified might be problematic if tested within seconds of midnight
        }
예제 #2
0
        public async Task RevUpASpecification()
        {
            //create a new rev with 2 sublevels with 3 choices each
            //then rev up with 3 sublevels and 4 choices each

            short  theEmpIdRev1      = 991; //Ben Johnson
            short  theEmpIdRev2      = 941; //Ed Wakefeild
            string theExtRev1Id      = "X";
            string theExtRev2Id      = "Y";
            int    samplePlanIdRev1  = 1;
            int    samplePlanIdRev2  = 7;
            int    numSublevelsRev1  = 2;
            int    numSubChoicesRev1 = 3;
            int    numSublevelsRev2  = 3;
            int    numSubChoicesRev2 = 4;
            string descPrefixRev1    = " - This is the inital rev. Rev: ";
            string descPrefixRev2    = " - This is the new rev. Rev: ";

            var theBaselineSpecModel = CreateBaselineSpecModel(theExtRev1Id, descPrefixRev1, theEmpIdRev1, samplePlanIdRev1, numSublevelsRev1, numSubChoicesRev1);
            int theCreatedSpecId     = await SpecService.CreateNewSpec(theBaselineSpecModel);

            var theExpectedRev2SpecModel    = CreateBaselineSpecModel(theExtRev2Id, descPrefixRev2, theEmpIdRev2, samplePlanIdRev2, numSublevelsRev2, numSubChoicesRev2);
            var theExpectedRev2SpecRevModel = theExpectedRev2SpecModel.SpecRevModels.ElementAt(0);

            theExpectedRev2SpecRevModel.SpecId = theCreatedSpecId;

            int theSpecId = await SpecService.RevUpSpec(theExpectedRev2SpecRevModel);

            //set up test values
            theExpectedRev2SpecRevModel.InternalRev = 11; //rev was incremented
            theExpectedRev2SpecRevModel.DateCreated = DateTime.Now.Date;
            theBaselineSpecModel.Id = theCreatedSpecId;

            var theNewRev2SpecModel = await SpecService.GetHydratedCurrentRevForSpec(theSpecId); //get new model for comparison

            Validate.ValidateModelCompleteness(theBaselineSpecModel, theNewRev2SpecModel, new List <Object>()
            {
                "SpecRevModels"
            });

            var theNewSpecRev2Model = theNewRev2SpecModel.SpecRevModels.ElementAt(1);

            Validate.ValidateModelCompleteness(theExpectedRev2SpecRevModel, theNewSpecRev2Model, new List <Object>()
            {
                "TimeCreated", "SubLevels", "SamplePlan"
            });

            /////////////////////////////////////////////////////////////
            //Verify rev2 is accurate
            var theNewRev2SpecSubLevelModels      = theNewSpecRev2Model.SubLevels;
            var theExpectedRev2SpecSubLevelModels = theExpectedRev2SpecRevModel.SubLevels;

            for (int i = 0; i < numSublevelsRev2; i++)
            {
                Validate.ValidateModelCompleteness(theExpectedRev2SpecSubLevelModels.ElementAt(i), theNewRev2SpecSubLevelModels.ElementAt(i),
                                                   new List <Object>()
                {
                    "Choices"
                });

                var theNewRev2SpecChoiceList      = theNewRev2SpecSubLevelModels.ElementAt(i).Choices;
                var theExpectedRev2SpecChoiceList = theExpectedRev2SpecSubLevelModels.ElementAt(i).Choices;

                for (int j = 0; j < numSubChoicesRev2; j++)
                {
                    Validate.ValidateModelCompleteness(theExpectedRev2SpecChoiceList.ElementAt(j), theNewRev2SpecChoiceList.ElementAt(j));
                }
            }
        }