예제 #1
0
        public Vessel InsertVessel(string vesselCode)
        {
            _logger.LogInformation("{0} | {1} | {2} | {3} | Begin DAL", DateTime.Now, "INFO", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            Vessel vessel = new Vessel {
                code = vesselCode
            };

            _dbContext.Add <Vessel>(vessel);
            _dbContext.SaveChanges();

            _logger.LogInformation("{0} | {1} | {2} | {3} | End DAL", DateTime.Now, "INFO", this.GetType().Name, MethodBase.GetCurrentMethod().Name);
            return(vessel);
        }
예제 #2
0
        public void TestInitialize()
        {
            var connection = new SqliteConnection("DataSource=:memory:");

            connection.Open();

            var options = new DbContextOptionsBuilder <FPSODbContext>()
                          .UseSqlite(connection).Options;

            _dbContext = new FPSODbContext(options);

            if (_dbContext != null)
            {
                _dbContext.Database.EnsureDeleted();
                _dbContext.Database.EnsureCreated();
            }

            _dbContext.Add <Vessel>(new Vessel {
                code = "1"
            });
            _dbContext.Add <Equipment>(new Equipment {
                Vesselcode = "1", name = "name1", code = "code1", location = "loc1", active = true
            });
            _dbContext.Add <Vessel>(new Vessel {
                code = "2"
            });
            _dbContext.Add <Equipment>(new Equipment {
                Vesselcode = "2", name = "name2", code = "code2", location = "loc2", active = true
            });
            _dbContext.SaveChanges();


            var loggerMockDal = new Mock <ILogger <FPSODal> >();

            _fpsoDal = new FPSODal(loggerMockDal.Object, _dbContext);

            var loggerMockService = new Mock <ILogger <FPSOServices> >();

            _fpsoServices = new FPSOServices(loggerMockService.Object, _fpsoDal);

            var loggerMockController = new Mock <ILogger <FPSOController> >();

            _fpsoController = new FPSOController(loggerMockController.Object, _fpsoServices);
        }