コード例 #1
0
        public async Task check_delimiter()
        {
            // Arrange
            IEnumerable <Condition> conditions = null;


            var lines = CreateEmptyLines();

            lines = lines.AddStringLine("Miguel;");

            var GoodLines = CreateEmptyLines().AddStringLine("T");

            var mock = mockRepository.Create <IOutputConfig>();

            mock.Setup(x => x.conditions).Returns(conditions);
            mock.Setup(x => x.delimiter).Returns(';');


            // Act
            var rules = CsvLineRuleCreator.Create(mock.Object);

            // Assert
            await Assert.ThrowsExceptionAsync <ConditionException>(async() => { await lines.CheckRules(rules); });

            await GoodLines.CheckRules(rules);
        }
コード例 #2
0
        public async Task check_string_equal_error()
        {
            // Arrange
            IEnumerable <Condition> conditions = new List <Condition>();

            conditions = conditions.AddEqual("string", "x");


            var lines = CreateEmptyLines();

            lines = lines.AddStringLine();

            var mock = mockRepository.Create <IOutputConfig>();

            mock.Setup(x => x.conditions).Returns(conditions);
            mock.Setup(x => x.delimiter).Returns(';');


            // Act
            var rules = CsvLineRuleCreator.Create(mock.Object);

            // Assert
            await Assert.ThrowsExceptionAsync <ConditionException>(async() =>
            {
                await lines.CheckRules(rules);
            });
        }
コード例 #3
0
        public void Create_null()
        {
            // Arrange
            IEnumerable <Condition> conditions = null;
            var mock = mockRepository.Create <IOutputConfig>();

            mock.Setup(x => x.conditions).Returns(conditions);
            mock.Setup(x => x.delimiter).Returns(';');


            // Act
            var rules = CsvLineRuleCreator.Create(mock.Object);

            // Assert
            Assert.IsTrue(rules.Count() == 1);
        }
コード例 #4
0
 internal static IServiceCollection AddConfiguration(this IServiceCollection services, IConfiguration config)
 {
     services.AddTransient(x => config);
     foreach (var item in CsvLineRuleCreator.Create(config.output))
     {
         services.AddTransient(x => item);
     }
     foreach (var item in CsvActionCreator.Create(config.output.replaces))
     {
         services.AddTransient(x => item);
     }
     foreach (var item in CsvActionCreator.Create(config.output.types))
     {
         services.AddTransient(x => item);
     }
     return(services);
 }
コード例 #5
0
        public async Task check_string_empty()
        {
            // Arrange
            var conditions = new List <Condition>();
            var lines      = CreateEmptyLines();
            var mock       = mockRepository.Create <IOutputConfig>();

            mock.Setup(x => x.conditions).Returns(conditions);
            mock.Setup(x => x.delimiter).Returns(';');


            // Act
            var rules = CsvLineRuleCreator.Create(mock.Object);

            // Assert
            await lines.CheckRules(rules);
        }