public void GivenXmlSerialaizerWhenInputIsStudentTestResultRepositoryThenOutIsXMLFileStudentTestResultRepository()
        {
            //Arrange
            StudentTestResult studentVasaTestResult = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult studentVovaTestResult = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult studentDimaTestResult = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);

            StudentTestResultRepository studentTestResultRepository = new StudentTestResultRepository();
            bool   fileIsExist = false;
            string path        = "../netcoreapp3.1/StudentTestResultRepository.xml";

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            Serialization.XmlSerialaizer <StudentTestResultRepository>(studentTestResultRepository);

            FileInfo fileInfo = new FileInfo(path);

            if (fileInfo.Exists)
            {
                fileIsExist = true;
            }

            //Assert
            Assert.AreEqual(true, fileIsExist);
        }
示例#2
0
        public void GivenAddStudentTestResultToBinaryTreeThenOutIsStudentBinaryTree()
        {
            //Arrange
            StudentTestResult              studentVasaTestResult       = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult              studentVovaTestResult       = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult              studentDimaTestResult       = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);
            StudentTestResultRepository    studentTestResultRepository = new StudentTestResultRepository();
            BinaryTree <StudentTestResult> expectedBinaryTree          = new BinaryTree <StudentTestResult>();

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            var actualBinaryTreeStudentTestResult = studentTestResultRepository.BinaryTreeStudentTestResult;

            expectedBinaryTree.Count = 3;
            expectedBinaryTree.Root  =
                new Node <StudentTestResult>(
                    studentVasaTestResult,
                    new Node <StudentTestResult>(
                        studentDimaTestResult), new Node <StudentTestResult>(
                        studentVovaTestResult));

            //Assert
            Assert.AreEqual(expectedBinaryTree, actualBinaryTreeStudentTestResult);
        }
        public void GivenXmlDeserializeWhenInputIsPathToFileOutIsNewStudentTestResultRepository(string pathToXmlFile)
        {
            //Arrange
            StudentTestResult studentVasaTestResult = new StudentTestResult(new Student(0, "Vasa"), new Test(TestItems.Algebra, new DateTime(10, 10, 10)), 100);
            StudentTestResult studentVovaTestResult = new StudentTestResult(new Student(1, "Andrey"), new Test(TestItems.Algebra, new DateTime(10, 10, 20)), 990);
            StudentTestResult studentDimaTestResult = new StudentTestResult(new Student(2, "Dima"), new Test(TestItems.Art, new DateTime(30, 1, 20)), 80);

            StudentTestResultRepository studentTestResultRepository = new StudentTestResultRepository();

            //Act
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVasaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentVovaTestResult);
            studentTestResultRepository.AddStudentTestResultToBinaryTree(studentDimaTestResult);

            var actualDeserialazedObj = Serialization.XmlDeserialize <StudentTestResultRepository>(pathToXmlFile);

            //Assert
            Assert.AreEqual(studentTestResultRepository, actualDeserialazedObj);
        }