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); }
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); }); }
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); }
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); }
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); }