Ejemplo n.º 1
0
        public void ParserCSVFormatToStudent()
        {
            // Expect Result:   Student {}
            DateTime oCurrentDate = DateTime.Now;
            string   szInput      = string.Format("High,Jhon,M,{0}"
                                                  , FileCSVHelper.ConvertTimeStampForCSV(oCurrentDate));
            Student oOutput       = FileCSVHelper.ParserCSVFormatToStudent(szInput);
            Student oExpectResult = HelpfulData.CreateOneStudent(oCurrentDate);

            Assert.AreEqual(oOutput.TimeStamp.ToLongDateString(), oExpectResult.TimeStamp.ToLongDateString());
        }
Ejemplo n.º 2
0
        public void ParserStudentToCSVFormat()
        {
            // Expect Result: High,Luke,M,20180604180120
            DateTime oCurrentDate   = DateTime.Now;
            Student  oInput         = HelpfulData.CreateOneStudent(oCurrentDate);
            string   szOutput       = FileCSVHelper.ParserStudentToCSVFormat(oInput);
            string   szExpectResult = string.Format("High,Jhon,M,{0}"
                                                    , FileCSVHelper.ConvertTimeStampForCSV(oCurrentDate));

            Assert.AreEqual(szOutput, szExpectResult);
        }
Ejemplo n.º 3
0
        public void Compare_NamePropertySetUp()
        {
            // a == b are equals if any property value matching
            // a.Name = ana , b.Name = ana :  true
            // a.Type = Kinder, b.Type = null
            // a.Type
            // a.Name = ana , b.Name = ana ; a.Type = kinder , b.Type = High :  false

            Student a = HelpfulData.CreateOneStudent(DateTime.Now);
            Student b = new Student
            {
                Name = "Jhon"
            };

            bool bOutput = _oManage.Compare(a, b);

            Assert.IsTrue(bOutput);
        }
Ejemplo n.º 4
0
        public void Write_A_Student_in_CSVFile()
        {
            // managing the information in a CSV file
            IFileFactory fileFactory   = new FileFactory();
            IHandleFile  handleFile    = fileFactory.GetFileType("CSV");
            string       szPath        = "inputTest.csv";
            Student      oInputStudent = HelpfulData.CreateOneStudent(DateTime.Now);

            handleFile.Path = szPath;
            handleFile.Write(oInputStudent);
            IEnumerable <Student> oStudents = handleFile.Read(szPath);

            Student oOutputStudent = null;

            foreach (var i in oStudents)
            {
                oOutputStudent = i;
            }

            Assert.AreEqual(oOutputStudent.TimeStamp.ToLongDateString(), oInputStudent.TimeStamp.ToLongDateString());
        }
        public void Add_New_Student()
        {
            List <Student>     oContext      = new List <Student>();
            Student            oInputStudent = HelpfulData.CreateOneStudent(DateTime.Now);
            IStudentRepository oRepo         = new StudentRepository(oContext);

            oRepo.Add(oInputStudent);

            IStudentManager manage = new StudentManager(oRepo, null);
            // Commandline   :   "name=jhon gender=M"
            string szInputCommandLine     = "name=jhon gender=M";
            IEnumerable <Student> oResult = manage.Search(szInputCommandLine);
            Student oExpectResult         = null;

            //should be match one
            foreach (var s in oResult)
            {
                oExpectResult = s;
            }
            Assert.IsNotNull(oExpectResult);
            Assert.AreEqual(oInputStudent.Name, oExpectResult.Name);
            Assert.AreEqual(oInputStudent.Gender, oExpectResult.Gender);
        }