public void CreateUpdateDeleteFetch() { // file system var path = "/shop/randomsilo/modern-web/backends/GoalTracker"; var project = "GoalTracker"; var outputPath = $"{path}/{project}.Infrastructure.Test/TestOutput/"; var databaseFile = GetDatabase(outputPath, MethodBase.GetCurrentMethod()); // logger ILogger logger = GetLogger($"{outputPath}/{MethodBase.GetCurrentMethod().ReflectedType.Name}_{MethodBase.GetCurrentMethod().Name}.log"); // database setup // - context IDatabaseContext databaseContext = new DatabaseContext( $"Data Source={databaseFile}" , "TestDb" , "TestSchema" , $"{path}/sql/sqlite/ALL.sql" ); Assert.NotNull(databaseContext); // - manager IManageDatabase databaseManager = new DatabaseManager(databaseContext); Assert.NotNull(databaseManager); // - create tables databaseManager.CreateDatabase(); // - repository var goalRepository = new GoalRepository(databaseManager, new GoalRepositorySql(), logger); Assert.NotNull(goalRepository); // faker BrashActionResult <Goal> result = null; var goalFaker = new GoalFaker(databaseManager, logger); Assert.NotNull(goalFaker); // create var goalCreateModel = goalFaker.GetOne(); result = goalRepository.Create(goalCreateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.GoalId > 0); // use model with id goalCreateModel = result.Model; // update var goalUpdateModel = goalFaker.GetOne(); goalUpdateModel.GoalId = goalCreateModel.GoalId; result = goalRepository.Update(goalUpdateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); // delete result = goalRepository.Delete(goalCreateModel); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); // fetch // - make fakes var fakes = goalFaker.GetMany(10); // - add fakes to database List <int?> ids = new List <int?>(); foreach (var f in fakes) { result = goalRepository.Create(f); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.GoalId >= 0); ids.Add(result.Model.GoalId); } // - get fakes from database foreach (var id in ids) { var model = new Goal() { GoalId = id }; result = goalRepository.Fetch(model); Assert.True(result.Status == BrashActionStatus.SUCCESS, result.Message); Assert.True(result.Model.GoalId >= 0); } }