Exemplo n.º 1
0
        public void SetUp()
        {
            if (!isSet)
            {
                isSet = true;

                category1 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();

                model1            = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
                model1.Name       = "DRT_01";
                model2            = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
                model2.Name       = "DRT_02";
                model3            = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
                model3.Name       = "DRT_03";
                deletedModel      = DatabaseTestDataProvider.ProvideRandomTestItemModel(category1);
                deletedModel.Name = "DRT_04";

                Repository.Save(model3);
                Repository.Save(deletedModel);
                Repository.Save(model2);
                Repository.Save(model1);
                UnitOfWork.Commit();

                Repository.Delete(deletedModel);
                UnitOfWork.Commit();
            }
        }
Exemplo n.º 2
0
        public void Should_Filter_Null_Or_Whitespace_Column_Correctly()
        {
            var category = DatabaseTestDataProvider.ProvideRandomTestItemCategory();

            category.Name = "   ";

            Repository.Save(category);
            UnitOfWork.Commit();

            TestItemCategory alias = null;
            var loadedCategory     = Repository
                                     .AsQueryOver(() => alias)
                                     .Where(RestrictionsExtensions.IsNullOrWhiteSpace(Projections.Property(() => alias.Name)))
                                     .And(() => alias.Id == category.Id)
                                     .SingleOrDefault <TestItemCategory>();

            Assert.IsNotNull(loadedCategory);
            Assert.AreEqual(category.Id, loadedCategory.Id);
        }
Exemplo n.º 3
0
        public void Should_Return_Correct_Items_Future_Count()
        {
            var category1 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
            var category2 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();
            var category3 = DatabaseTestDataProvider.ProvideRandomTestItemCategory();

            category1.Name = "QEIT_" + category1.Name.Substring(10);
            category2.Name = "QEIT_" + category1.Name.Substring(10);
            category3.Name = "QEIT_" + category1.Name.Substring(10);

            Repository.Save(category1);
            Repository.Save(category2);
            Repository.Save(category3);
            UnitOfWork.Commit();

            var query       = Repository.AsQueryable <TestItemCategory>().Where(c => c.Name.StartsWith("QEIT_"));
            var countFuture = query.ToRowCountFutureValue();
            var future      = query.ToFuture();

            Assert.AreEqual(future.ToList().Count, 3);
            Assert.AreEqual(countFuture.Value, 3);
        }