예제 #1
0
        public IActionResult addPerson([FromBody] FreeTime freeTime)
        {
            //validate data
            if (!DiaryValidation.isFreeTimeLegal(freeTime, diaryService))
            {
                dynamic error = new JObject();
                error.ErrorCode   = "UNAUTHORIZED_API_METHOD";
                error.Description = "illegal data";

                return(Json(JsonConvert.SerializeObject(error)));
            }

            diaryService.addName(freeTime);
            return(Json(diaryService.getJSON()));
        }
예제 #2
0
        public void TestMethod1()
        {
            DiaryService diaryService = new DiaryService(new HandleJSON());

            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("Eliad", "08:00", "12:00"), diaryService), true);
            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("", "12:00", "10:00"), diaryService), false);
            Assert.AreEqual(DiaryValidation.isFreeTimeLegal(new FreeTime("Eliad", "12:30", "16:00"), diaryService), false);


            Assert.AreEqual(diaryService.isAppearInEnd("12:00"), true);
            Assert.AreEqual(diaryService.isAppearInEnd("18:00"), false);

            Assert.AreEqual(diaryService.isAppearInStart("12:00"), true);
            Assert.AreEqual(diaryService.isAppearInStart("17:50"), false);
        }