public void AddNewCoinTest()
        {
            var coin = new Coin(EnumCoin.One);

            var result = RepositoryCoin.Add(coin, 5);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.Quantity, 5);
            Assert.AreEqual(result.Entity, coin);
            Assert.AreNotEqual(result.Id, 0);
        }
Ejemplo n.º 2
0
        public ActionResult Put(int id, int quantity)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            var machineStackCoin = _repositoryCoins.Get(id);

            if (machineStackCoin == null)
            {
                return(NotFound());
            }


            _repositoryCoins.Add(machineStackCoin.Entity, quantity);

            return(Ok(_mapper.Map <CoinModel>(machineStackCoin)));
        }
        public void Init()
        {
            var options = new DbContextOptionsBuilder <ApplicationContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var context = new ApplicationContext(options);

            RepositoryCoin = new RepositoryCoin(context);
            RepositoryCoin.Add(_coin, _quality);
        }
Ejemplo n.º 4
0
        public CoinController(IApplicationContext db, IMapper mapper)
        {
            _repositoryCoins = new RepositoryCoin(db);
            _mapper          = mapper;

            foreach (EnumCoin par in Enum.GetValues(typeof(EnumCoin)))
            {
                if (_repositoryCoins.Get(new Coin(par)) == null)
                {
                    _repositoryCoins.Add(new Coin(par), 0);
                }
            }
        }