コード例 #1
0
        public void ManyToManyTest()
        {
            using (AdventureWorks adventureWorks = new AdventureWorks())
            {
                Product[] products = adventureWorks
                                     .Products
#if NETFX
                                     .Include(product => product.ProductProductPhotos.Select(productProductPhoto => productProductPhoto.ProductPhoto))
#else
                                     .Include(product => product.ProductProductPhotos).ThenInclude(productProductPhoto => productProductPhoto.ProductPhoto)
#endif
                                     .ToArray();
                EnumerableAssert.Multiple(products);
                EnumerableAssert.Any(products.Where(product => product.ProductProductPhotos.Any(productProductPhoto => productProductPhoto.ProductPhoto != null)));

                ProductPhoto[] photos = adventureWorks.ProductPhotos
#if NETFX
                                        .Include(photo => photo.ProductProductPhotos.Select(productProductPhoto => productProductPhoto.Product))
#else
                                        .Include(photo => photo.ProductProductPhotos).ThenInclude(productProductPhoto => productProductPhoto.Product)
#endif
                                        .ToArray();
                EnumerableAssert.Multiple(photos);
                Assert.IsTrue(photos.All(photo => photo.ProductProductPhotos.Any(productProductPhoto => productProductPhoto.Product != null)));
            }
        }
コード例 #2
0
 public void CompiedQueryTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         string[] productNames = adventureWorks.GetProductNames(539.99M).ToArray();
         EnumerableAssert.Any(productNames);
     }
 }
コード例 #3
0
 public void StoredProcedureWithSingleResultTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ISingleResult <ManagerEmployee> employees = adventureWorks.uspGetManagerEmployees(2);
         EnumerableAssert.Any(employees);
     }
 }
コード例 #4
0
 public void StoredProcedureWithComplexTypeTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ObjectResult <ManagerEmployee> employees = adventureWorks.GetManagerEmployees(2);
         EnumerableAssert.Any(employees);
     }
 }
コード例 #5
0
 public void StoreProcedureWithMultipleResultsTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
         using (IMultipleResults results = adventureWorks.uspGetCategoryAndSubcategory(1))
         {
             EnumerableAssert.Single(results.GetResult <ProductCategory>());
             EnumerableAssert.Any(results.GetResult <ProductSubcategory>());
         }
 }
コード例 #6
0
 public void QueryAllParentProcesses()
 {
     Win32Process[] processes = ProcessHelper.ByName("svchost.exe").ToArray();
     EnumerableAssert.Any(processes);
     processes.ForEach(process =>
     {
         IEnumerable <Win32Process> parentProcesses = ProcessHelper.AllParentProcess(process.ProcessId.Value);
         EnumerableAssert.Multiple(parentProcesses);
     });
 }
コード例 #7
0
 public void QueryParentProcess()
 {
     Win32Process[] processes = ProcessHelper.ByName("svchost.exe").ToArray();
     EnumerableAssert.Any(processes);
     processes.ForEach(process =>
     {
         Win32Process parentProcess = ProcessHelper.ParentProcess(process.ProcessId.Value);
         Assert.IsNotNull(parentProcess);
     });
 }
コード例 #8
0
 public void TableTest()
 {
     using (AdventureWorks adventureWorks = new AdventureWorks())
     {
         ProductCategory[] categories = adventureWorks
                                        .ProductCategories
                                        .Include(category => category.ProductSubcategories)
                                        .ToArray();
         EnumerableAssert.Any(categories);
         Assert.IsTrue(categories.Any(category => category.ProductSubcategories.Any()));
     }
 }
コード例 #9
0
        public void OneToOneTest()
        {
            using (AdventureWorks adventureWorks = new AdventureWorks())
            {
                Person[] people = adventureWorks
                                  .People
                                  .Include(person => person.Employee)
                                  .ToArray();
                EnumerableAssert.Multiple(people);
                EnumerableAssert.Any(people.Where(person => person.Employee != null));

                Employee[] employees = adventureWorks.Employees.Include(employee => employee.Person).ToArray();
                EnumerableAssert.Multiple(employees);
                Assert.IsTrue(employees.All(employee => employee.Person != null));
            }
        }
コード例 #10
0
        public void ScalarValuedFunctionTest()
        {
            using (AdventureWorks adventureWorks = new AdventureWorks())
            {
                IQueryable <Product> products = adventureWorks
                                                .Products
                                                .Where(product => product.ListPrice <= adventureWorks.ufnGetProductListPrice(999, DateTime.Now));
                EnumerableAssert.Any(products);

                decimal?price = adventureWorks.ufnGetProductListPrice(999, DateTime.Now);
                Assert.IsTrue(price > 1);

                decimal?cost = adventureWorks.ufnGetProductStandardCost(999, DateTime.Now);
                Assert.IsNotNull(cost);
                Assert.IsTrue(cost > 1);

                products = adventureWorks
                           .Products
                           .Where(product => product.ListPrice >= adventureWorks.ufnGetProductStandardCost(999, DateTime.Now));
                EnumerableAssert.Any(products);
            }
        }