示例#1
0
 public void Dispose()
 {
     _optionsBuilder = null;
     foreach (var cmd in _dbContext.Commands)
     {
         _dbContext.Commands.Remove(cmd);
     }
     _dbContext.SaveChanges();
     _dbContext.Dispose();
     _mapper        = null;
     _commanderRepo = null;
     _controller    = null;
 }
示例#2
0
        public CommandsControllerTests()
        {
            _optionsBuilder = new DbContextOptionsBuilder <CommanderContext>();
            _optionsBuilder.UseInMemoryDatabase("UnitTestInMemBD");
            _dbContext = new CommanderContext(_optionsBuilder.Options);

            //Mapper
            var myProfile     = new CommandsProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile));

            _mapper = new Mapper(configuration);

            _commanderRepo = new SqlCommanderRepo(_dbContext);

            _controller = new CommandsController(_commanderRepo, _mapper);
        }
示例#3
0
        public void CreateContextTest()
        {
            using (var context = new CommanderContext(ContextOptions))
            {
                var sqlRepo = new SqlCommanderRepo(context);

                var controller = new CommandsController(sqlRepo, getMapper());

                var request = new CommandCreateDto {
                    HowTo = "Unit Test 1", Line = "Unit Test 1", Platform = "Unit Test 1"
                };

                var resp = controller.CreateCommand(request);



                _output.WriteLine($"{resp.ToString()}");

                //Assert.IsType(, resp.Result);
            }
        }