Exemplo n.º 1
0
        public void ReadGenericFilter_Errors()
        {
            var entityRepos  = new SystemFilterRepository();
            var genericRepos = NewRepos(entityRepos);

            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Operation = "x"
                                                                   } }), "both property filter and predefined filter are null");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Value = "x"
                                                                   } }), "both property filter and predefined filter are null");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                   } }), "both property filter and predefined filter are null");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Filter = "xx", Property = "yy"
                                                                   } }), "both property filter and predefined filter are set", "xx", "yy");

            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Filter = "System.String", Operation = "xxx"
                                                                   } }), "Filter", "System.String", "Operation", "xxx", "Matches", "NotMatches");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Filter = "System.String", Value = 123
                                                                   } }), "System.String", "System.Int32");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Property = "Name", Operation = "xxx"
                                                                   } }), "Operation", "xxx");
            TestUtility.ShouldFail(() => genericRepos.Load(new[] { new FilterCriteria {
                                                                       Property = "Name", Value = "xxx"
                                                                   } }), "Property", "Name", "Operation");
        }
Exemplo n.º 2
0
        public void ReadGenericFilter_Defaults()
        {
            var entityRepos  = new SystemFilterRepository();
            var genericRepos = NewRepos(entityRepos);

            Assert.AreEqual("0001-01-01T00:00:00", genericRepos
                            .Load(new[] { new FilterCriteria {
                                              Filter = "System.DateTime"
                                          } })
                            .Single().Name);
            Assert.AreEqual("00000000-0000-0000-0000-000000000000", genericRepos
                            .Load(new[] { new FilterCriteria {
                                              Filter = "System.Guid"
                                          } })
                            .Single().Name);
        }