Exemplo n.º 1
0
        private IMapper InitializeMapper()
        {
            var profile       = new CommandsProfile();
            var configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile));

            return(new Mapper(configuration));
        }
 // METHODS
 public void Dispose()
 {
     mockRepository = null;
     realProfile    = null;
     configuration  = null;
     mapper         = null;
 }
Exemplo n.º 3
0
 public CommandsControllerTests()
 {
     _mockRepo      = new Mock <ICommandAPIRepo>();
     _realProfile   = new CommandsProfile();
     _configuration = new MapperConfiguration(cfg => cfg.AddProfile(_realProfile));
     _mapper        = new Mapper(_configuration);
 }
 // CONSTRUCTOR
 public CommandControllerTests()
 {
     mockRepository = new Mock <ICommandAPIRepository>();
     realProfile    = new CommandsProfile();
     configuration  = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
     mapper         = new Mapper(configuration);
 }
 public void Dispose()
 {
     _mockApiRepo   = null;
     _mapper        = null;
     _configuration = null;
     _realProfile   = null;
 }
Exemplo n.º 6
0
 public CommandsControllerTests()
 {
     mockRepo      = new Mock <ICommandAPIRepo>();
     profile       = new CommandsProfile();
     configuration = new MapperConfiguration(cfg => cfg.AddProfile(profile));
     mapper        = new Mapper(configuration);
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     mockRepo      = null;
     mapper        = null;
     configuration = null;
     profile       = null;
 }
 public CommandsControllerTests()
 {
     _mockRespository = new Mock <IPersistCommand>();
     _realProfile     = new CommandsProfile();
     _configuration   = new MapperConfiguration(config => config.AddProfile(_realProfile));
     _mapper          = new Mapper(_configuration);
 }
 public void Dispose()
 {
     _mockRespository = null;
     _realProfile     = null;
     _configuration   = null;
     _mapper          = null;
 }
Exemplo n.º 10
0
 public CommandsControllerTests()
 {
     mockRepo      = new Mock <IStorageBroker>();
     realProfile   = new CommandsProfile();
     configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
     mapper        = new Mapper(configuration);
 }
Exemplo n.º 11
0
 public CommandsControllerTests()
 {
     mockRepo = mockRepo = new Mock <ICommandAPIRepo>();
     mockRepo.Setup(repo => repo.GetAllCommands()).Returns(GetCommands(0));
     realProfile   = new CommandsProfile();
     configuration = new MapperConfiguration(cfg => cfg.
                                             AddProfile(realProfile));
     mapper = new Mapper(configuration);
 }
Exemplo n.º 12
0
        public CommandsControllerTests()
        {
            // create a mock object of ICommandAPIRepo
            mockRepo = new Mock <ICommandAPIRepo>();

            // Creates AutoMapper profile object
            realProfile   = new CommandsProfile();
            configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
            mapper        = new Mapper(configuration);
        }
Exemplo n.º 13
0
 public CommandsControllerTests()
 {
     // set up a new “mock” instance of the repository (only the interface is needed. It takes the service implementation)
     mockRepo = new Mock <ICommandAPIRepo>();
     // Using a real automapper (not mocked) with our existing profiles:
     // We set up a CommandsProfile instance and assign it to a MapperConfiguration.
     realProfile = new CommandsProfile();
     // We create a concrete instance of IMapper and give it our MapperConfiguration.
     configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
     // creating new mapper (not mocked) and passing the profile configuration.
     mapper = new Mapper(configuration);
 }
Exemplo n.º 14
0
        public void GetCommandItems_ReturnsZeroItems_WhenDBIsEmpty()
        {
            var mockRepo = new Mock <ICommandAPIRepo>();

            mockRepo.Setup(repo =>
                           repo.GetAllCommands()).Returns(GetCommands(0));

            var realProfile   = new CommandsProfile();
            var configuration = new MapperConfiguration(cfg =>
                                                        cfg.AddProfile(realProfile));
            IMapper mapper = new Mapper(configuration);

            var controller = new CommandsController(mockRepo.Object, mapper);
        }
Exemplo n.º 15
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);
        }
Exemplo n.º 16
0
        public void GetCommandItems_ReturnsZeroItems_WhenDBIsEmpty()
        {
            //Arrange
            var mockRepo = new Mock <ICommandAPIRepo>();

            mockRepo.Setup(repo => repo.GetAllCommands()).Returns(GetCommands(0));

            var     realProfile   = new CommandsProfile();
            var     configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
            IMapper mapper        = new Mapper(configuration);
            var     controller    = new CommandsController(mockRepo.Object, mapper);

            //Act
            var result = controller.GetAllCommands();

            //Assert
            Assert.IsType <OkObjectResult>(result.Result);
        }
Exemplo n.º 17
0
        public void GetCommandItems_Returns200OK_WhenDBIsEmpty()
        {
            //Arrange
            Mock <ICommandAPIRepo> mockRepo = new Mock <ICommandAPIRepo>();

            mockRepo.Setup(repo => repo.GetAllCommands()).Returns(GetCommands(0));

            CommandsProfile     realProfile   = new CommandsProfile();
            MapperConfiguration configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
            IMapper             mapper        = new Mapper(configuration);

            CommandsController controller = new CommandsController(mockRepo.Object, mapper);

            //Act
            ActionResult <IEnumerable <CommandReadDto> > result = controller.GetAllCommands();

            //Assert
            Assert.IsType <OkObjectResult>(result.Result);
        }
        public void GetCommandItems_ReturnsZeroItems_WhenDBIsEmpty()
        {
            //Arrange
            var mockRepo = new Mock <ICommandAPIRepo>();

            mockRepo.Setup(repo => repo.GetAllCommands()).Returns(GetCommands(0));

            var     realProfile   = new CommandsProfile();
            var     configuration = new MapperConfiguration(cfg => cfg.AddProfile(realProfile));
            IMapper mapper        = new Mapper(configuration);

            //We need to create an instance of our CommandsController class

            var controller = new CommandsController(mockRepo.Object, mapper);

            //Act


            //Assert
        }