public void InitializeRepo()
        {
            _id = 1;
            _teams = new Dictionary<int, Team>();
            _mockTeamRepo = new Mock<IGenericRepository>();
            _testTeam = new Team {ID = 1};
            _testTeamStorageManager = new TeamStorageManager(_mockTeamRepo.Object);

            // Read item - Team
            _mockTeamRepo.Setup(r => r.Read<Team>(It.IsAny<int>()))
                .Returns<int>(id => _teams.First(e => e.Key == id).Value);

            // Read items - Team
            _mockTeamRepo.Setup(r => r.Read<Team>()).Returns(_teams.Values.AsQueryable());

            // Create - Team
            _mockTeamRepo.Setup(r => r.Create(It.IsAny<Team>())).Callback<Team>(team =>
            {
                var nextId = _id++;
                team.ID = nextId;
                _teams.Add(nextId, team);
            });

            // Update - Team
            _mockTeamRepo.Setup(r => r.Update(It.IsAny<Team>())).Callback<Team>(team =>
            {
                if (_teams.ContainsKey(team.ID))
                {
                    _teams[team.ID] = team;
                }
            });

            // Delete - Team
            _mockTeamRepo.Setup(r => r.Delete(It.IsAny<Team>())).Callback<Team>(team => { _teams.Remove(team.ID); });
        }
        public void InitializeRepo()
        {
            _id = 1;
            _users = new Dictionary<int, User>();
            _mockUserRepo = new Mock<IGenericRepository>();
            _testUser = new User {ID = 1};
            _testUserStorageManager = new TeamStorageManager(_mockUserRepo.Object);

            // Read item - User
            _mockUserRepo.Setup(r => r.Read<User>(It.IsAny<int>()))
                .Returns<int>(id => _users.First(e => e.Key == id).Value);

            // Read items - User
            _mockUserRepo.Setup(r => r.Read<User>()).Returns(_users.Values.AsQueryable());

            // Create - User
            _mockUserRepo.Setup(r => r.Create(It.IsAny<User>())).Callback<User>(user =>
            {
                var nextId = _id++;
                user.ID = nextId;
                _users.Add(nextId, user);
            });

            // Update - User
            _mockUserRepo.Setup(r => r.Update(It.IsAny<User>())).Callback<User>(user =>
            {
                if (_users.ContainsKey(user.ID))
                {
                    _users[user.ID] = user;
                }
            });

            // Delete - User
            _mockUserRepo.Setup(r => r.Delete(It.IsAny<User>())).Callback<User>(user => { _users.Remove(user.ID); });
        }
        public void InitializeTest()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways<IntegrationTestContext>());
            var testContext = new IntegrationTestContext();
            testContext.Database.Initialize(true);

            _testRepo = new EntityFrameworkGenericRepository<IntegrationTestContext>(testContext);
            _teamStorageManager = new TeamStorageManager(_testRepo);
            _userManager = new UserManager(_teamStorageManager);
        }
Exemple #4
0
 public UserManager(TeamStorageManager storageManager)
 {
     _storageManager = storageManager;
 }
Exemple #5
0
 public UserManager()
 {
     _storageManager = new TeamStorageManager();
 }
Exemple #6
0
 public TeamManager()
 {
     _teamStorageManager = new TeamStorageManager();
 }
Exemple #7
0
 public TeamManager(TeamStorageManager storageManager)
 {
     _teamStorageManager = storageManager;
 }