public Team Update(Team item)
 {
     Repo.Update(item);
     Unit.SaveChanges();
     return item;
     
 }
        public IHttpActionResult Post(string id, Team team)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            Logic.Create(team);
            MemLogic.Create(new Membership
                {
                    AccountId = id,
                    Status = MembershipStatus.Admin,
                    TeamId = team.Id,
                    Date = DateTime.UtcNow
                });
            return Ok(team);
        }
        public void TeamPostGet()
        {
            Team team = new Team
            {
                Access = true,
                Name = "Work together!"
            };

            TeamController controller = new TeamController(new MockDatabase());

            controller.Create(1, team);

            var result = controller.Get(1) as OkNegotiatedContentResult<Team>;
            Assert.IsNotNull(result);

            Assert.AreEqual("Work together!", result.Content.Name);
            Assert.AreEqual(true, result.Content.Access);
        }
        public void TeamPostPutGet()
        {
            Team team = new Team
            {
                Access = true,
                Name = "Work together!"
            };

            TeamController controller = new TeamController(new MockDatabase());

            team = (controller.Create(1, team) as OkNegotiatedContentResult<Team>).Content;

            team.Access = false;
            team.Name = "Nah";

            var result = controller.Get(team.Id) as OkNegotiatedContentResult<Team>;
            Assert.IsNotNull(result);

            Assert.AreEqual("Nah", result.Content.Name);
            Assert.AreEqual(false, result.Content.Access);
        }
        public IHttpActionResult Put(Team team)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            try
            {
                Logic.Update(team);
                return Ok(team);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TeamExists(team.Id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }
        }
 public void Put(Team team)
 {
     teams[team.Id] = team;
 }
        public void TeamRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Team>> dbSet = new Mock<DbSet<Team>>();

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

            TeamRepository repo = new TeamRepository(factory.Object);

            var Team = new Team();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(Team));
            dbSet.InSequence(sequence).Setup(e => e.Find(Team.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Team.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Team.Id));
            repo.Create(Team);
            repo.Get(Team.Id);
            repo.Update(Team);
            repo.Delete(Team.Id);
        }
        public void TeamLogic()
        {
            Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>();
            Mock<ITeamRepository> repo = new Mock<ITeamRepository>();

            TeamLogic logic = new TeamLogic(uow.Object, repo.Object);

            var team = new Team();
            var sequence = new MockSequence();
            repo.InSequence(sequence).Setup(r => r.Create(team));
            repo.InSequence(sequence).Setup(r => r.Update(team));
            repo.InSequence(sequence).Setup(r => r.Get(team.Id));
            logic.Create(team);
            logic.Update(team);
            logic.Get(team.Id);
        }
 public Team Create(Team item)
 {
     Repo.Create(item);
     Unit.SaveChanges();
     return item;
 }
 private List<Account> GetMembers(Team t)
 {
     List<Membership> mems = MembershipLogic.GetByTeam(t.Id).ToList();
     List<Account> Members = new List<Account>();
     foreach (Membership m in mems)
     {
         if (m.Status.IsMember())
         {
             Members.Add(aLogic.Get(m.AccountId));
         }
     }
     return Members;
 }