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))); } }
public void CompiedQueryTest() { using (AdventureWorks adventureWorks = new AdventureWorks()) { string[] productNames = adventureWorks.GetProductNames(539.99M).ToArray(); EnumerableAssert.Any(productNames); } }
public void StoredProcedureWithSingleResultTest() { using (AdventureWorks adventureWorks = new AdventureWorks()) { ISingleResult <ManagerEmployee> employees = adventureWorks.uspGetManagerEmployees(2); EnumerableAssert.Any(employees); } }
public void StoredProcedureWithComplexTypeTest() { using (AdventureWorks adventureWorks = new AdventureWorks()) { ObjectResult <ManagerEmployee> employees = adventureWorks.GetManagerEmployees(2); EnumerableAssert.Any(employees); } }
public void StoreProcedureWithMultipleResultsTest() { using (AdventureWorks adventureWorks = new AdventureWorks()) using (IMultipleResults results = adventureWorks.uspGetCategoryAndSubcategory(1)) { EnumerableAssert.Single(results.GetResult <ProductCategory>()); EnumerableAssert.Any(results.GetResult <ProductSubcategory>()); } }
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); }); }
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); }); }
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())); } }
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)); } }
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); } }