コード例 #1
0
        public void CodeBookServiceGetTest()
        {
            CodeBookReaderService service = new CodeBookReaderService();
            CodeBookCollection    source  = service.Get();

            Assert.NotNull(source);
            Assert.NotEmpty(source.Items);
        }
コード例 #2
0
        public void CodeBookValidateItemTest(string key, string value)
        {
            CodeBookReaderService service = new CodeBookReaderService();
            CodeBookCollection    source  = service.Get();

            bool flag = source.IsValidValue(key, value, out string message);

            Assert.True(flag, message);
        }
コード例 #3
0
        public void CodeBookFailedItemTest(string key, string value)
        {
            CodeBookReaderService service = new CodeBookReaderService();
            CodeBookCollection    source  = service.Get();

            bool flag = source.IsValidValue(key, value, out string message);

            Assert.False(flag);

            this.Output.WriteLine(message);
        }
コード例 #4
0
        /// <summary>
        /// This function returns <see cref="CodeBookCollection"/> collection retried from
        /// CSV source file.
        /// </summary>
        /// <returns>The  <see cref="CodeBookCollection"/> items collection.</returns>
        public CodeBookCollection Get()
        {
            if (string.IsNullOrEmpty(this.FileName))
            {
                throw new ArgumentNullException($"The file name of the source is not defined.");
            }

            List <CodeBookProfiler> source = this.GetCsvData <CodeBookProfiler, CodeBookProfilerMap>(this.FileName);
            CodeBookCollection      target = new CodeBookCollection();

            foreach (CodeBookProfiler item in source)
            {
                target.Add(item.FieldName, item.Value, item.DescriptionLocalized);
            }
            return(target);
        }