public void CreateNullTimeStartThrowException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(null)); Assert.Equal("TimeStart can't be null", ex.Message); }
public void CreateTimeStartIncorrectFormatThrowException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); var timeStart = new TimeStart() { id = 1, timeStart = "24355" }; Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(timeStart)); Assert.Equal("TimeStart string has to be in format of HH:mm (ex 09:45)", ex.Message); }
public void CreateTimeStartNotNumbersThrowException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); var timeStart = new TimeStart() { id = 1, timeStart = "hh:mm" }; Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(timeStart)); Assert.Equal("TimeStart string has to be numbers", ex.Message); }
public void CreateTimeStartIncorrectLengthTooShortThrowException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); var timeStart = new TimeStart() { id = 1, timeStart = "4444" }; Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(timeStart)); Assert.Equal("TimeStart string is too long/short, follow format HH:mm", ex.Message); }
public void CreateTimeStartWithEmptyTimeThrowsException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); var timeStart = new TimeStart() { id = 1, timeStart = "" }; Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(timeStart)); Assert.Equal("TimeStart can't be empty", ex.Message); }
public void CreateTimeStartWithIncorrectHoursOutsideLowerBoundThrowException() { var tsRepo = new Mock <ITimeStartRepo>(); var tsService = new TimeStartService(tsRepo.Object); var timeStart = new TimeStart() { id = 1, timeStart = "-1:45" }; Exception ex = Assert.Throws <InvalidDataException>(() => tsService.CreateTimeStart(timeStart)); Assert.Equal("TimeStart string hours has to be 00-23", ex.Message); }