public void WhenSetNullConditionThenSetBothConditionToNull()
 {
     var hbmFilter = new HbmFilter();
     var mapper = new FilterMapper("MyFilter", hbmFilter);
     mapper.Condition(null);
     hbmFilter.condition.Should().Be.Null();
     hbmFilter.Text.Should().Be.Null();
 }
 public void WhenSetMultiLineConditionThenSetTextCondition()
 {
     var hbmFilter = new HbmFilter();
     var mapper = new FilterMapper("MyFilter", hbmFilter);
     mapper.Condition("aFiled = :aParameter" + Environment.NewLine + "AND anotherField = :anotherParam");
     hbmFilter.condition.Should().Be.Null();
     hbmFilter.Text.Should().Not.Be.Null();
     hbmFilter.Text.Should().Have.SameSequenceAs("aFiled = :aParameter", "AND anotherField = :anotherParam");
 }
        public void WhenSetEmptyConditionThenSetBothConditionToNull()
        {
            var hbmFilter = new HbmFilter();
            var mapper = new FilterMapper("MyFilter", hbmFilter);
            mapper.Condition(string.Empty);
            hbmFilter.condition.Should().Be.Null();
            hbmFilter.Text.Should().Be.Null();

            mapper.Condition("    ");
            hbmFilter.condition.Should().Be.Null();
            hbmFilter.Text.Should().Be.Null();
        }
Пример #4
0
		public FilterMapper(string filterName, HbmFilter filter)
		{
			if (filterName == null)
			{
				throw new ArgumentNullException("filterName");
			}
			if (string.Empty.Equals(filterName.Trim()))
			{
				throw new ArgumentOutOfRangeException("filterName", "Invalid filter-name: the name should contain no blank characters.");
			}
			if (filter == null)
			{
				throw new ArgumentNullException("filter");
			}
			this.filter = filter;
			this.filter.name = filterName;
		}
 public void Filter(string filterName, Action<IFilterMapper> filterMapping)
 {
     if (filterMapping == null)
     {
         filterMapping = x => { };
     }
     var hbmFilter = new HbmFilter();
     var filterMapper = new FilterMapper(filterName, hbmFilter);
     filterMapping(filterMapper);
     var filters = classMapping.filter != null ? classMapping.filter.ToDictionary(f => f.name, f => f): new Dictionary<string, HbmFilter>(1);
     filters[filterName] = hbmFilter;
     classMapping.filter = filters.Values.ToArray();
 }
 public void WhenSetSingleLineConditionThenSetSimpleCondition()
 {
     var hbmFilter = new HbmFilter();
     var mapper = new FilterMapper("MyFilter", hbmFilter);
     mapper.Condition("aFiled = :aParameter");
     hbmFilter.condition.Should().Be("aFiled = :aParameter");
     hbmFilter.Text.Should().Be.Null();
 }
 public void WhenSetSingleLineConditionThenResetTextCondition()
 {
     var hbmFilter = new HbmFilter();
     var mapper = new FilterMapper("MyFilter", hbmFilter);
     mapper.Condition("aFiled = :aParameter" + Environment.NewLine + "AND anotherField = :anotherParam");
     mapper.Condition("aFiled = :aParameter");
     mapper.Condition("aFiled = :aParameter");
     hbmFilter.Text.Should().Be.Null();
 }
 public void WhenCreatedForceTheNameOfTheFilter()
 {
     var hbmFilter = new HbmFilter();
     new FilterMapper("MyFilter", hbmFilter);
     hbmFilter.name.Should().Be("MyFilter");
 }