Exemplo n.º 1
0
        public void Create_GivenOneStudentInFile_ShouldReturnAListWithTwoElements()
        {
            var json = "[{ \"Name\":\"Pepe\", \"LastName\":\"Perez\", \"Age\": 20}]";

            File.WriteAllText(FileName, json);
            var student = new Student
            {
                Name     = "Pepe",
                LastName = "Perez",
                Age      = 21
            };
            var jsonStudentDao = new JsonStudentDao();

            jsonStudentDao.Create(student);
            var jsonList = jsonStudentDao.GetAll();

            Assert.AreEqual(2, jsonList.Count);
        }
Exemplo n.º 2
0
        public void Create_GivenAnEmptyFile_ShouldReturnAListWithOneElement()
        {
            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }
            var student = new Student
            {
                Name     = "Pepe",
                LastName = "Perez",
                Age      = 21
            };
            var jsonStudentDao = new JsonStudentDao();

            jsonStudentDao.Create(student);
            var jsonList = jsonStudentDao.GetAll();

            Assert.AreEqual(1, jsonList.Count);
        }