public void Test_MinMaxBothZero()
		{
			CountSpecification s = new CountSpecification(0, 0, null);
			Assert.IsTrue(s.Test(new int[] {}).Success);
			Assert.IsFalse(s.Test(new int[] { 1 }).Success);
			Assert.IsFalse(s.Test(new int[] { 1, 2 }).Success);
		}
Esempio n. 2
0
        public void Test_NonEnumerable()
        {
            CountSpecification s = new CountSpecification(1, 1, null);

            // testing an object that does not implement IEnumerable should throw
            Assert.IsFalse(s.Test(new object()).Success);
        }
Esempio n. 3
0
        public void Test_MinMaxBothZero()
        {
            CountSpecification s = new CountSpecification(0, 0, null);

            Assert.IsTrue(s.Test(new int[] {}).Success);
            Assert.IsFalse(s.Test(new int[] { 1 }).Success);
            Assert.IsFalse(s.Test(new int[] { 1, 2 }).Success);
        }
		public void Test_MinMaxBothLargest()
		{
			// this should always be false unless someone has fills an array with MaxValue items
			CountSpecification s = new CountSpecification(int.MaxValue, int.MaxValue, null);
			Assert.IsFalse(s.Test(new int[] { }).Success);
			Assert.IsFalse(s.Test(new int[] { 1 }).Success);
			Assert.IsFalse(s.Test(new int[] { 1, 2 }).Success);
		}
		public void Test_MinMaxRange1()
		{
			CountSpecification s = new CountSpecification(1, 2, null);
			Assert.IsFalse(s.Test(new int[] { }).Success);
			Assert.IsTrue(s.Test(new int[] { 1 }).Success);
			Assert.IsTrue(s.Test(new int[] { 1, 2 }).Success);
			Assert.IsFalse(s.Test(new int[] { 1, 2, 3 }).Success);
		}
Esempio n. 6
0
        public void Test_MinMaxRange1()
        {
            CountSpecification s = new CountSpecification(1, 2, null);

            Assert.IsFalse(s.Test(new int[] { }).Success);
            Assert.IsTrue(s.Test(new int[] { 1 }).Success);
            Assert.IsTrue(s.Test(new int[] { 1, 2 }).Success);
            Assert.IsFalse(s.Test(new int[] { 1, 2, 3 }).Success);
        }
Esempio n. 7
0
        public void Test_MinMaxBothLargest()
        {
            // this should always be false unless someone has fills an array with MaxValue items
            CountSpecification s = new CountSpecification(int.MaxValue, int.MaxValue, null);

            Assert.IsFalse(s.Test(new int[] { }).Success);
            Assert.IsFalse(s.Test(new int[] { 1 }).Success);
            Assert.IsFalse(s.Test(new int[] { 1, 2 }).Success);
        }
        public void Test_Count_Options3()
        {
            ISpecification s = _factory.GetSpecification("count_options3");

            Assert.IsInstanceOfType(typeof(CountSpecification), s);

            CountSpecification s1 = (CountSpecification)s;

            Assert.AreEqual(1, s1.Min);
            Assert.AreEqual(2, s1.Max);
        }
        public void Test_Count_Default()
        {
            ISpecification s = _factory.GetSpecification("count_default");

            Assert.IsInstanceOfType(typeof(CountSpecification), s);

            CountSpecification s1 = (CountSpecification)s;

            Assert.AreEqual(0, s1.Min);
            Assert.AreEqual(int.MaxValue, s1.Max);
        }
Esempio n. 10
0
		public void Test_Filter()
		{
			CountSpecification s1 = new CountSpecification(1, 1, AlwaysTrue);
			Assert.IsFalse(s1.Test(new int[] { }).Success);
			Assert.IsTrue(s1.Test(new int[] { 1 }).Success);
			Assert.IsFalse(s1.Test(new int[] { 1, 2 }).Success);

			CountSpecification s2 = new CountSpecification(1, 1, AlwaysFalse);
			Assert.IsFalse(s2.Test(new int[] { }).Success);
			Assert.IsFalse(s2.Test(new int[] { 1 }).Success);
			Assert.IsFalse(s2.Test(new int[] { 1, 2 }).Success);
		}
Esempio n. 11
0
        public async Task <ActionResult <Pagination <GemReturnDTO> > > GetGemsList([FromQuery] GemParams gemParams)
        {
            var countSpec  = new CountSpecification(gemParams);
            var filterSpec = new FilterSpecification(gemParams);
            var gemList    = await _repo.GetGemListWithSpec(filterSpec);

            var itemsCount = await _repo.CountAsync(countSpec);

            var data = _mapper.Map <IReadOnlyList <Gem>, IReadOnlyList <GemReturnDTO> >(gemList);

            return(Ok(new Pagination <GemReturnDTO>(gemParams.PageIndex, gemParams.PageSize, itemsCount, data)));
        }
        public void Test_Count_Filtered()
        {
            ISpecification s = _factory.GetSpecification("count_filtered");

            Assert.IsInstanceOfType(typeof(CountSpecification), s);

            CountSpecification s1 = (CountSpecification)s;

            Assert.AreEqual(1, s1.Min);
            Assert.AreEqual(2, s1.Max);
            Assert.IsNotNull(s1.FilterSpecification);
            Assert.IsInstanceOfType(typeof(TrueSpecification), s1.FilterSpecification);
        }
Esempio n. 13
0
        public void Test_Filter()
        {
            CountSpecification s1 = new CountSpecification(1, 1, AlwaysTrue);

            Assert.IsFalse(s1.Test(new int[] { }).Success);
            Assert.IsTrue(s1.Test(new int[] { 1 }).Success);
            Assert.IsFalse(s1.Test(new int[] { 1, 2 }).Success);

            CountSpecification s2 = new CountSpecification(1, 1, AlwaysFalse);

            Assert.IsFalse(s2.Test(new int[] { }).Success);
            Assert.IsFalse(s2.Test(new int[] { 1 }).Success);
            Assert.IsFalse(s2.Test(new int[] { 1, 2 }).Success);
        }
		public void Test_NonEnumerable()
		{
			CountSpecification s = new CountSpecification(1, 1, null);

			// testing an object that does not implement IEnumerable should throw
			Assert.IsFalse(s.Test(new object()).Success);
		}
		public void Test_NegativeRange()
		{
			CountSpecification s = new CountSpecification(-1, 0, null);
		}
		public void Test_InvalidRange()
		{
			CountSpecification s = new CountSpecification(1, 0, null);
		}
Esempio n. 17
0
 public void Test_InvalidRange()
 {
     CountSpecification s = new CountSpecification(1, 0, null);
 }
Esempio n. 18
0
 public void Test_NegativeRange()
 {
     CountSpecification s = new CountSpecification(-1, 0, null);
 }