Exemple #1
0
        public void SinglePoem_ExpectListWithSamePoem()
        {
            //Arrange
            var poems        = new PoemBuilder().Default().BuildCollection(size: 1).ToList();
            var queryable    = poems.AsQueryable();
            var expectResult = poems;

            //Act
            var spec       = ListPoemsByLastModifiedDateSpec.CreateSpecification();
            var testResult = queryable.OrderByDescending(spec.OrderByDesc);

            //Assert
            Assert.Null(spec.Criteria);
            Assert.Null(spec.OrderBy);
            Assert.Equal(expectResult, testResult);
        }
Exemple #2
0
        public void PoemsWithDescModifiedDate_ExpectListOrderedDesc()
        {
            //Arrange
            var poems = new PoemBuilder().Default().BuildCollection(size: 3).ToList();

            poems[0].LastModifiedDateUTC = DateTime.UtcNow.AddDays(-1);
            poems[1].LastModifiedDateUTC = DateTime.UtcNow.AddDays(-2);
            poems[2].LastModifiedDateUTC = DateTime.UtcNow.AddDays(-3);
            var queryable    = poems.AsQueryable();
            var expectResult = poems;

            //Act
            var spec       = ListPoemsByLastModifiedDateSpec.CreateSpecification();
            var testResult = queryable.OrderByDescending(spec.OrderByDesc);

            //Assert
            Assert.Equal(expectResult, testResult);
        }