Exemple #1
0
        public void InfoWithRequiredFieldsAndInvalidResponseTypeIsInvalid()
        {
            Info info = new Info();

            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event     = "Event";
            info.Urgency   = Urgency.Expected;
            info.Severity  = Severity.Extreme;
            info.Certainty = Certainty.Likely;
            info.ResponseTypes.Add((ResponseType)123);

            Alert alert = new Alert();

            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);

            Assert.False(infoValidator.IsValid);

            var infoErrors = from error in infoValidator.Errors
                             where error.GetType() == typeof(ResponseTypeError)
                             select error;

            Assert.NotEmpty(infoErrors);
        }
Exemple #2
0
        public void setup()
        {
            string requestJson = @"{'name':'Brandon DSouza',
                        'deskOrientation':0,
                        'current':{
                            'bazookaInfo':
                                { 'jobTitle':'Intern',
                                'department':'IT',
                                'group':'Unknown',
                                'managerId':'Joe Kolodz',
                                'jobTemplate':'IT Intern'},
                            'ultiproInfo':
                                {'jobTitle':'Intern',
                                'department':'IT',
                                'group':'Unknown',
                                'supervisor':'Joe Kolodz',
                                'other':''},
                            'deskInfo':
                                {'deskNumber':'5-13',
                                'office':'34658df'},
                            'phoneInfo':
                                {'phoneNumber':'|1|8472357349|7349|'}
                        },
                        '$$hashKey':'007',
                        'future':
                            {'bazookaInfo':
                                {'jobTitle':'President',
                                'department':'Human Resources',
                                'group':'T7',
                                'managerId':'Joe Kolodz',
                                'jobTemplate':'3476sdf',
                                'securityItemRights':'324dfgrt'},
                            'deskInfo':
                                {'deskNumber':'sdf345345',
                                'office':'df3445645'},
                            'ultiproInfo':
                                {'jobTitle':'sdf',
                                'department':'5dfsdf',
                                'supervisor': 'Joe Kolodz',
                                'other':'sdf23342'},
                            'phoneInfo':
                                {'phoneNumber':'4234234234234'}},
                        'emailInfo':
                            {'groupsToBeAddedTo':'fdsf34545vf',
                            'groupsToBeRemovedFrom':'345fgf'},
                        'ReviewInfo':
                            {'filesToBeAddedTo':'sdfsdfgf',
                             'filesToBeRemovedFrom':'34345'}}";

            _reqObject = JObject.Parse(requestJson);
            //_deskObject = JObject.Parse(
            _deskController    = new DeskController();
            _requestController = new RequestFormController();
            _validator         = new InfoValidator();
        }
Exemple #3
0
 public void TwoInfosInAnAlertWithNoneOfTheRequiredElementsAreInvalid()
 {
     var alert = new Alert();
     // two infos in alert
     alert.Info.Add(new Info());
     alert.Info.Add(new Info());
     var alertValidatorDouble = new InfoValidator(alert);
     var validationErrorsDouble = alertValidatorDouble.Errors;
     // 10 errors detected >> mising sublements x 2
     Assert.False(alertValidatorDouble.IsValid);
     Assert.Equal(10, validationErrorsDouble.Count());
 }
Exemple #4
0
        public void OneInfoWithNoneOfTheRequiredElementsIsInvalid()
        {
            var alert = new Alert();

            // one info in alert
            alert.Info.Add(new Info());
            var alertValidatorSingle = new InfoValidator(alert);
            var validationErrorsSingle = alertValidatorSingle.Errors;
            // 5 errors detected >> missing subelements : Category , Certainty , Event , Severity , Urgency
            Assert.False(alertValidatorSingle.IsValid);
            Assert.Equal(5, validationErrorsSingle.Count());
        }
 public void setup()
 {
     _deskNum   = "THX1138";
     _topLeftX  = 0;
     _topLeftY  = 1;
     _orient    = 0;
     _floorNum  = 5;
     _empID     = 117;
     _testDesk  = new DeskDB();
     _validator = new InfoValidator();
     _testDesk.InsertInformationIntoDeskDB(_deskNum, _topLeftX, _topLeftY, _orient, _floorNum, _empID);
 }
Exemple #6
0
        public void TwoInfosInAnAlertWithAllRequiredElementsAreValid()
        {
            var alert = new Alert();
            var info = InfoCreator.CreateValidInfo();

            // two infos in alert
            alert.Info.Add(info);
            alert.Info.Add(info);
            var doubleAlertValidator = new InfoValidator(alert);
            // the info should be valid
            Assert.True(doubleAlertValidator.IsValid);
            Assert.Equal(0, doubleAlertValidator.Errors.Count());
        }
Exemple #7
0
        public void OneInfoWithAllRequiredElementsIsValid()
        {
            var alert = new Alert();
            var info = InfoCreator.CreateValidInfo();

            // one info in alert
            alert.Info.Add(info);
            var singleAlertValidator = new InfoValidator(alert);
            var singleErrorsValidation = singleAlertValidator.Errors;
            // the info should be valid
            Assert.True(singleAlertValidator.IsValid);
            Assert.Equal(0, singleErrorsValidation.Count());
        }
Exemple #8
0
        public void InfoWithRequiredFieldsIsValid()
        {
            Info info = new Info();
            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event = "Event";
            info.Urgency = Urgency.Expected;
            info.Severity = Severity.Extreme;
            info.Certainty = Certainty.Likely;

            Alert alert = new Alert();
            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);
            Assert.True(infoValidator.IsValid);
        }
Exemple #9
0
        public void InfoWithRequiredFieldsIsValid()
        {
            Info info = new Info();

            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event     = "Event";
            info.Urgency   = Urgency.Expected;
            info.Severity  = Severity.Extreme;
            info.Certainty = Certainty.Likely;

            Alert alert = new Alert();

            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);

            Assert.True(infoValidator.IsValid);
        }
Exemple #10
0
        public void InfoWithRequiredFieldsExceptCertaintyIsInvalid()
        {
            Info info = new Info();
            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event = "Event";
            info.Urgency = Urgency.Expected;
            info.Severity = Severity.Extreme;
            //info.Certainty is missing

            Alert alert = new Alert();
            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);
            Assert.False(infoValidator.IsValid);

            var infoErrors = from error in infoValidator.Errors
                             where error.GetType() == typeof(CertaintyRequiredError)
                             select error;
            Assert.NotEmpty(infoErrors);
        }
Exemple #11
0
        public void InfoWithRequiredFieldsAndInvalidResponseTypeIsInvalid()
        {
            Info info = new Info();
            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event = "Event";
            info.Urgency = Urgency.Expected;
            info.Severity = Severity.Extreme;
            info.Certainty = Certainty.Likely;
            info.ResponseTypes.Add((ResponseType)123);

            Alert alert = new Alert();
            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);
            Assert.False(infoValidator.IsValid);

            var infoErrors = from error in infoValidator.Errors
                             where error.GetType() == typeof(ResponseTypeError)
                             select error;
            Assert.NotEmpty(infoErrors);
        }
Exemple #12
0
        public void InfoWithRequiredFieldsExceptCertaintyIsInvalid()
        {
            Info info = new Info();

            //Required Fields : Categories,Event,Urgency,Severity,Certainty
            info.Categories.Add(Category.CBRNE);
            info.Event    = "Event";
            info.Urgency  = Urgency.Expected;
            info.Severity = Severity.Extreme;
            //info.Certainty is missing

            Alert alert = new Alert();

            alert.Info.Add(info);
            var infoValidator = new InfoValidator(alert);

            Assert.False(infoValidator.IsValid);

            var infoErrors = from error in infoValidator.Errors
                             where error.GetType() == typeof(CertaintyRequiredError)
                             select error;

            Assert.NotEmpty(infoErrors);
        }
 public void setup()
 {
     _validator = new InfoValidator();
 }