public async Task Should_Find_Single_Entity() { // ARRANGE var blogArray = await InsertBlogsAsync(); var blogRepo = DIProvider.GetRepository <Blog>(); // ACT var dogBlog = await blogRepo.GetAsync(blogs => blogs.SingleOrDefault(b => b.Url.EndsWith("dogs"))); // ASSERT Assert.IsNotNull(dogBlog); }
public async Task Should_Insert_Entities() { // ARRANGE var blogArray = await InsertBlogsAsync(); var repo = DIProvider.GetRepository <Blog>(); // ACT var blogCount = await repo.GetAsync(q => q.Count()); // ASSERT Assert.AreEqual(blogCount, blogArray.Length); }
public async Task Should_Find_Two_Cats_And_One_Dog_Blogs() { // ARRANGE var blogArray = await InsertBlogsAsync(); var blogRepo = DIProvider.GetRepository <Blog>(); // ACT var dogCount = await blogRepo.GetAsync(blogs => blogs.Count(b => b.Url.EndsWith("dogs"))); var catBlogs = await blogRepo.GetAsync(blogs => blogs.Where(b => b.Url.Contains("cat")).ToArray()); // ASSERT Assert.AreEqual(1, dogCount); Assert.AreEqual(2, catBlogs.Length); }
public async Task Should_Delete_Product() { // ARRANGE await InsertCategoriesAndProductsAsync(); var productsRepo = DIProvider.GetSqliteRepository <Product>(); // ACT var product = await productsRepo.GetAsync(q => q.Where(c => c.Name == "Citroën").Single()); productsRepo.Remove(product); await productsRepo.SaveChangesAsync(); // ASSERT Assert.AreEqual(23, productsRepo.All().Count()); }
public async Task Should_Insert_Categories_And_Products() { // ARRANGE await InsertCategoriesAndProductsAsync(); var categoriesRepo = DIProvider.GetSqliteRepository <Category>(); var productsRepo = DIProvider.GetSqliteRepository <Product>(); // ACT var categoriesCount = await categoriesRepo.GetAsync(q => q.Count()); var productsCount = await productsRepo.GetAsync(q => q.Count()); // ASSERT Assert.AreEqual(2, categoriesCount); Assert.AreEqual(24, productsCount); }
public async Task Should_Update_Entity() { // ARRANGE var blogArray = await InsertBlogsAsync(); var blogRepo = DIProvider.GetRepository <Blog>(); // ACT var dogBlog = await blogRepo.GetAsync(blogs => blogs.Single(b => b.Url.EndsWith("dogs"))); dogBlog.Url = dogBlog.Url.Replace("dogs", "bulldogs"); await blogRepo.SaveChangesAsync(); var blogRepo2 = DIProvider.GetRepository <Blog>(); dogBlog = await blogRepo2.GetAsync(blogs => blogs.Single(b => b.Url.EndsWith("dogs"))); // ASSERT Assert.AreEqual(dogBlog.Url, "http://sample.com/bulldogs"); }
public TriggerProgram() { _triggerRepository = DIProvider.GetServiceProvider().GetService <ISQLTriggerRepository>(); _documentRepository = DIProvider.GetServiceProvider().GetService <ISQLDocumentRepository>(); }
public DocumentProgram() { _repository = DIProvider.GetServiceProvider().GetService <ISQLDocumentRepository>(); }
public BaseProgram() { _collectionRepository = DIProvider.GetServiceProvider().GetService <ISQLCollectionRepository>(); }
public DatabaseProgram() : base() { _repository = DIProvider.GetServiceProvider().GetService <ISQLDatabaseRepository>(); }
static void Main(string[] args) { Console.Title = "*** ** *MS Network 18 - Neum* ** ***"; DIProvider.CreateServiceCollection(); bool runApp = true; while (runApp) { Console.Clear(); ProgramHelper.Stars(); ProgramHelper.Title(); ProgramHelper.Stars(); Option(); Console.Write("> "); OptionEnum option = (OptionEnum)Convert.ToInt16(Console.ReadLine()); switch (option) { #region << EXIT >> case OptionEnum.EXIT: { runApp = false; break; } #endregion << EXIT >> #region << Database options >> case OptionEnum.CreateDatabase: { DatabaseProgram program = new DatabaseProgram(); Task.Run(() => program.CreateDatabase()).Wait(); break; } case OptionEnum.DeleteDatabase: { DatabaseProgram program = new DatabaseProgram(); Task.Run(() => program.DeleteDatabase()).Wait(); break; } case OptionEnum.ListDatabase: { DatabaseProgram program = new DatabaseProgram(); Task.Run(() => program.ListDatabase()).Wait(); break; } #endregion << Database options >> #region << Collection options >> case OptionEnum.CreateCollection: { CollectionProgram program = new CollectionProgram(); Task.Run(() => program.CreateCollection()).Wait(); break; } case OptionEnum.DeleteCollection: { CollectionProgram program = new CollectionProgram(); Task.Run(() => program.DeleteCollection()).Wait(); break; } case OptionEnum.ReadCollectionsOfDatabase: { CollectionProgram program = new CollectionProgram(); Task.Run(() => program.ReadAllCollectionsFromDatabase()).Wait(); break; } #endregion << Collection options >> #region << Document options >> case OptionEnum.ReadDocument: { DocumentProgram program = new DocumentProgram(); program.ReadDocument().Wait(); break; } case OptionEnum.DeleteDocument: { DocumentProgram program = new DocumentProgram(); program.DeleteDocument().Wait(); break; } case OptionEnum.InsertDocument: { DocumentProgram program = new DocumentProgram(); program.InsertDocument().Wait(); break; } case OptionEnum.UpdateDocument: { DocumentProgram program = new DocumentProgram(); program.UpdateDocument().Wait(); break; } #endregion << Document options >> #region << Stored procedure case OptionEnum.CallStoredProcedure: { StoredProcedureProgram program = new StoredProcedureProgram(); program.Run().Wait(); break; } #endregion << Stored procedure #region << Trigger >> case OptionEnum.ExecuteWithTrigger: { TriggerProgram program = new TriggerProgram(); program.Run().Wait(); break; } #endregion << Trigger >> #region << UDF >> case OptionEnum.UseUDF: { UDFProgram program = new UDFProgram(); program.Run().Wait(); break; } #endregion << UDF >> #region << Exception >> case OptionEnum.Exception: { ExceptionProgram program = new ExceptionProgram(); program.Run().Wait(); break; } #endregion << Exception >> #region << Default >> default: { runApp = false; break; } #endregion << Default >> } if (runApp) { ProgramHelper.Wait(); } } }
IUnitOfWork GetUnitOfWork() => DIProvider.GetService <IUnitOfWork>();
public StoredProcedureProgram() : base() { _baseRepository = DIProvider.GetServiceProvider().GetService <ISQLStoredProcedureRepository>(); }
public UDFProgram() { _udfRepository = DIProvider.GetServiceProvider().GetService <ISQLUDFRepository>(); _documentRepository = DIProvider.GetServiceProvider().GetService <ISQLDocumentRepository>(); }
public ExceptionProgram() { _documentRepository = DIProvider.GetServiceProvider().GetService <ISQLDocumentRepository>(); }
public BaseProgram() { _collectionRepository = DIProvider.GetServiceProvider().GetService <ISQLCollectionRepository>(); DatabaseId = _collectionRepository.DatabaseId; CollectionId = _collectionRepository.CollectionId; }