Пример #1
0
        public void CreateNullTimeStopThrowException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(null));

            Assert.Equal("TimeEnd can't be null", ex.Message);
        }
Пример #2
0
        public void CreateTimeEndIncorrectFormatThrowException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            var timeEnd = new TimeEnd()
            {
                id      = 1,
                timeEnd = "24355"
            };

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(timeEnd));

            Assert.Equal("TimeEnd string has to be in format of HH:mm (ex 09:45)", ex.Message);
        }
Пример #3
0
        public void CreateTimeEndNotNumbersThrowException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            var timeEnd = new TimeEnd()
            {
                id      = 1,
                timeEnd = "hh:mm"
            };

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(timeEnd));

            Assert.Equal("TimeEnd string has to be numbers", ex.Message);
        }
Пример #4
0
        public void CreateTimeEndIncorrectLengthTooShortThrowException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            var timeEnd = new TimeEnd()
            {
                id      = 1,
                timeEnd = "4444"
            };

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(timeEnd));

            Assert.Equal("TimeEnd string is too long/short, follow format HH:mm", ex.Message);
        }
Пример #5
0
        public void CreateTimeEndWithEmptyTimeThrowsException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            var timeEnd = new TimeEnd()
            {
                id      = 1,
                timeEnd = ""
            };

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(timeEnd));

            Assert.Equal("TimeEnd can't be empty", ex.Message);
        }
Пример #6
0
        public void CreateTimeEndWithIncorrectHoursOutsideLowerBoundThrowException()
        {
            var teRepo    = new Mock <ITimeEndRepo>();
            var teService = new TimeEndService(teRepo.Object);

            var timeEnd = new TimeEnd()
            {
                id      = 1,
                timeEnd = "-1:45"
            };

            Exception ex = Assert.Throws <InvalidDataException>(() =>
                                                                teService.CreateTimeEnd(timeEnd));

            Assert.Equal("TimeEnd string hours has to be 00-23", ex.Message);
        }