示例#1
0
        public void DataConvertion_Properties_SeparatorGetterThrowsNotImplementedException()
        {
            // Prepare and Execute:
            var obj = new XMLDataConverter();

            _ = obj.Separator;
        }
示例#2
0
        public void DataConvertion_Methods_ListOfStringsConvertedToListOfITaskObjects()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "<task Name=\"TaskName\" Description=\"TaskDescription\" StartDate=\"01.01.2021 00:00:00\" EndDate=\"02.01.2021 00:00:05\" Complete=\"True\" Category=\"TaskCategory\" />";
            var taskMock = new Mock <ITask>();

            taskMock.SetupAllProperties();
            var listString = new List <string>
            {
                data,
                data,
                data
            };
            var listTask = new List <ITask>
            {
                taskMock.Object,
                taskMock.Object,
                taskMock.Object
            };
            // Execute:
            var result = obj.ToObject(taskMock.Object, listString);

            // Verify:
            CollectionAssert.AreEqual(listTask, (List <ITask>)result);
        }
示例#3
0
        public void DataConvertion_Methods_ICategoryObjectConvertedToStringObject()
        {
            // Prepare and Execute:
            var obj = new XMLDataConverter();

            obj.ToObject(new Mock <ICategory>().Object);
        }
示例#4
0
        public void DataConvertion_Methods_ListOfITaskObjectsConvertedToListOfStringObjectsWithOneNull()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var taskMock = new Mock <ITask>();

            taskMock.Setup(x => x.Name).Returns("TaskName");
            taskMock.Setup(x => x.Description).Returns("TaskDescription");
            taskMock.Setup(x => x.StartDate).Returns(DateTime.Parse("01.01.2021 00:00:00"));
            taskMock.Setup(x => x.EndDate).Returns(DateTime.Parse("02.01.2021 00:00:05"));
            taskMock.Setup(x => x.Complete).Returns(true);
            taskMock.Setup(x => x.Category).Returns("TaskCategory");
            var wrongTaskMock = new Mock <ITask>();
            var listTask      = new List <ITask>
            {
                taskMock.Object,
                wrongTaskMock.Object,
                taskMock.Object
            };
            // Execute:
            var result = obj.ToObject(listTask);

            // Verify:
            CollectionAssert.Contains((List <string>)result, null);
        }
示例#5
0
        public void DataConvertion_Methods_ListOfITaskObjectsConvertedToListOfStringObjects()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "<task Name=\"TaskName\" Description=\"TaskDescription\" StartDate=\"01.01.2021 00:00:00\" EndDate=\"02.01.2021 00:00:05\" Complete=\"True\" Category=\"TaskCategory\" />";
            var taskMock = new Mock <ITask>();

            taskMock.Setup(x => x.Name).Returns("TaskName");
            taskMock.Setup(x => x.Description).Returns("TaskDescription");
            taskMock.Setup(x => x.StartDate).Returns(DateTime.Parse("01.01.2021 00:00:00"));
            taskMock.Setup(x => x.EndDate).Returns(DateTime.Parse("02.01.2021 00:00:05"));
            taskMock.Setup(x => x.Complete).Returns(true);
            taskMock.Setup(x => x.Category).Returns("TaskCategory");
            var listString = new List <string>
            {
                data,
                data,
                data
            };
            var listTask = new List <ITask>
            {
                taskMock.Object,
                taskMock.Object,
                taskMock.Object
            };
            // Execute:
            var result = obj.ToObject(listTask);

            // Verify:
            CollectionAssert.AreEqual(listString, (List <string>)result);
        }
示例#6
0
 public void DataConvertion_Properties_SeparatorSetterThrowsNotImplementedException()
 {
     // Prepare and Execute:
     _ = new XMLDataConverter
     {
         Separator = 'a'
     };
 }
示例#7
0
        public void DataConvertion_Methods_WrongITaskObjectConvertionToXML()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var taskMock = new Mock <ITask>();
            // Execute:
            var result = obj.ToObject(taskMock.Object);

            // Verify:
            Assert.IsNull(result);
        }
示例#8
0
        public void DataConvertion_Methods_WrongXMLStringInStringConvertionToITaskObjectFails()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "abc";
            var taskMock = new Mock <ITask>();
            // Execute:
            var result = obj.ToObject(taskMock.Object, data);

            // Verify:
            Assert.IsNull(result);
        }
示例#9
0
        public void DataConvertion_Methods_StringConvertionToITaskObjectFailed()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "<task Name=\"\" Description=\"\" StartDate=\"\" EndDate=\"\" Complete=\"\" Category=\"\" />";
            var taskMock = new Mock <ITask>();
            // Execute:
            var result = obj.ToObject(taskMock.Object, data);

            // Verify:
            Assert.IsNull(result);
        }
示例#10
0
        public void DataConvertion_Methods_ListOfICategoryObjectsConvertedToListOfStringObjects()
        {
            // Prepare and Execute:
            var obj  = new XMLDataConverter();
            var list = new List <ICategory>()
            {
                new Mock <ICategory>().Object,
                new Mock <ICategory>().Object,
                new Mock <ICategory>().Object
            };

            obj.ToObject(list);
        }
示例#11
0
        public void DataConvertion_Properties_ListOfStringObjectsConvertedToListOfICategoryObjects()
        {
            // Prepare and Execute:
            var obj  = new XMLDataConverter();
            var list = new List <string>()
            {
                string.Empty,
                string.Empty,
                string.Empty
            };

            obj.ToObject(new Mock <ICategory>().Object, list);
        }
示例#12
0
        public void DataConvertion_Methods_StringConvertedToITaskObject()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "<task Name=\"TaskName\" Description=\"TaskDescription\" StartDate=\"01.01.2021 00:00:00\" EndDate=\"02.01.2021 00:00:05\" Complete=\"True\" Category=\"TaskCategory\" />";
            var taskMock = new Mock <ITask>();

            taskMock.SetupAllProperties();
            // Execute:
            obj.ToObject(taskMock.Object, data);
            // Verify:
            taskMock.VerifySet(x => x.Name        = "TaskName");
            taskMock.VerifySet(x => x.Description = "TaskDescription");
            taskMock.VerifySet(x => x.StartDate   = DateTime.Parse("01.01.2021 00:00:00"));
            taskMock.VerifySet(x => x.EndDate     = DateTime.Parse("02.01.2021 00:00:05"));
            taskMock.VerifySet(x => x.Complete    = true);
            taskMock.VerifySet(x => x.Category    = "TaskCategory");
        }
示例#13
0
        public void DataConvertion_Methods_ITaskObjectConvertedToXMLString()
        {
            // Prepare:
            var obj      = new XMLDataConverter();
            var data     = "<task Name=\"TaskName\" Description=\"TaskDescription\" StartDate=\"01.01.2021 00:00:00\" EndDate=\"02.01.2021 00:00:05\" Complete=\"True\" Category=\"TaskCategory\" />";
            var taskMock = new Mock <ITask>();

            taskMock.Setup(x => x.Name).Returns("TaskName");
            taskMock.Setup(x => x.Description).Returns("TaskDescription");
            taskMock.Setup(x => x.StartDate).Returns(DateTime.Parse("2021-01-01 00:00:00"));
            taskMock.Setup(x => x.EndDate).Returns(DateTime.Parse("2021-01-02 00:00:05"));
            taskMock.Setup(x => x.Complete).Returns(true);
            taskMock.Setup(x => x.Category).Returns("TaskCategory");
            // Execute:
            var result = obj.ToObject(taskMock.Object);

            // Verify:
            Assert.AreEqual(data, result);
        }