コード例 #1
0
        public Attainment Update(Attainment item)
        {
            Repo.Update(item);
            Unit.SaveChanges();
            return item;

        }
コード例 #2
0
        public void AttainmentRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Attainment>> dbSet = new Mock<DbSet<Attainment>>();

            factory.Setup(m => m.CreateDbSet<Attainment>()).Returns(dbSet.Object);

            AttainmentRepository repo = new AttainmentRepository(factory.Object);

            var attainment = new Attainment();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(attainment));
            dbSet.InSequence(sequence).Setup(e => e.Find(attainment.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(attainment.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(attainment.Id));
            repo.Create(attainment);
            repo.Get(attainment.Id);
            repo.Update(attainment);
            repo.Delete(attainment.Id);
        }
コード例 #3
0
        public void AttainmentLogic()
        {
            Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>();
            Mock<IAttainmentRepository> repo = new Mock<IAttainmentRepository>();
            Mock<IBadgeRepository> badgeRepo = new Mock<IBadgeRepository>();
            Mock<IActivityRepository> activityRepo = new Mock<IActivityRepository>();
            Mock<ITargetRepository> targetRepo = new Mock<ITargetRepository>();
            Mock<ITeamLogic> teamLogic = new Mock<ITeamLogic>();

            AttainmentLogic logic = new AttainmentLogic(uow.Object, repo.Object, badgeRepo.Object, activityRepo.Object, targetRepo.Object, teamLogic.Object);

            var attainment = new Attainment();
            var sequence = new MockSequence();
            repo.InSequence(sequence).Setup(r => r.Create(attainment));
            repo.InSequence(sequence).Setup(r => r.Update(attainment));
            repo.InSequence(sequence).Setup(r => r.Get(attainment.Id));
            repo.InSequence(sequence).Setup(r => r.Delete(attainment.Id));
            logic.Create(attainment);
            logic.Update(attainment);
            logic.Get(attainment.Id);
            logic.Delete(attainment.Id);
        }
コード例 #4
0
        // PUT api/Activity/5
        public IHttpActionResult Put(Attainment item)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                return Ok(Logic.Update(item));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Logic.Exists(item.Id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }
        }
コード例 #5
0
 public IHttpActionResult Post(Attainment item)
 {
     Attainment Created = Logic.Create(item);
     return Ok(Created);
 }