public RecommendationsController(RecommendationsRepository repo, RecPhotosRepository photosrepo, RelationshipsRepository relationshipsrepo, UsersRepository usersrepo) { _repo = repo; _photosRepo = photosrepo; _relationshipsRepo = relationshipsrepo; _usersrepo = usersrepo; }
public void Exercise6() { VillainRepository villainRepository = new VillainRepository(); MinionRepository minionRepository = new MinionRepository(); List <Villain> villains = new List <Villain>(villainRepository.GetAll()); foreach (var item in villains) { Console.WriteLine(item.Id + " " + item.Name); } Console.WriteLine("Enter id of a villain to delete:"); int id = Convert.ToInt32(Console.ReadLine()); Villain v = villainRepository.GetById(id); if (v == null) { Console.WriteLine("No such villain found"); return; } int r = RelationshipsRepository.DeleteMinionsOfVillain(v); villainRepository.Delete(id); Console.WriteLine(v.Name + " was deleted."); Console.WriteLine(r + " minions were released."); return; }
public void Exercise4() { // Declare repositories MinionRepository minionRepository = new MinionRepository(); TownRepository townRepository = new TownRepository(); VillainRepository villainRepository = new VillainRepository(); //Promote the towns foreach (var item in townRepository.GetAll()) { Console.WriteLine($"Id : {item.Id}\t Name: {item.Name}"); } //Get the Minion data Console.WriteLine("Enter Minion Info:Name-Age-TownName"); string line = Console.ReadLine(); var minionLines = line.Split('-'); Town town = townRepository.GetByName(minionLines[2]); //if town does not exist condition if (town == null) { town = new Town(); town.Name = minionLines[2]; town.CountryId = 1; townRepository.Insert(town); town = townRepository.GetByName(town.Name); Console.WriteLine($"Town {town.Name} was added to the database."); } //Read info of its villain Console.WriteLine("Enter Villain Name"); string villainName = Console.ReadLine(); Villain villain = villainRepository.GetByName(villainName); //if town does not exist condition if (villain == null) { villain = new Villain(); villain.Name = villainName; villain.EvilnessFactorId = 3; villainRepository.Insert(villain); villain = villainRepository.GetByName(villain.Name); Console.WriteLine($"Villain {villain.Name} was added to the database."); } Minion minion = new Minion(); minion.Name = minionLines[0]; minion.Age = Convert.ToInt32(minionLines[1]); minion.TownId = town.Id; minionRepository.Insert(minion); minion = minionRepository.GetByName(minion.Name); if (RelationshipsRepository.AddNewMinionToVillain(minion, villain) > 0) { Console.WriteLine($"Successfully added {minion.Name} to be minion of {villain.Name}."); } Console.ReadKey(); }
public async Task WhenGetRelationshipsGetsCalled() { Setup(); AuthService.Setup(service => service.AuthorizeSelf(It.IsAny <string>(), It.IsAny <Guid>())).Returns(true); RelationshipsRepository.Setup(repository => repository.GetRelationshipsByIdAndType( It.IsAny <Guid>(), It.IsAny <RelationshipType>())).ReturnsAsync(_relationships); _result = await RelationshipsController.GetRelationships(_userId, RelationshipTypeId); }
public async Task WhenAreAlreadyFriendsGetsCalled() { Setup(); RelationshipsRepository.Setup(repository => repository.GetRelationshipByIdsAndType(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <RelationshipType>())).ReturnsAsync(new Relationship()); _result = await RelationshipsService.AreAlreadyFriends(_userOneId, _userTwoId); }
public async Task WhenAddFriendGetsCalled() { Setup(); _relationship = new Relationship(_userOneId, _userTwoId, RelationshipType.Friend); RelationshipsRepository.Setup(repository => repository.CreateRelationship(It.IsAny <Relationship>())) .Callback <Relationship>(rel => _usedRelationship = rel); await RelationshipsService.AddFriend(_userOneId, _userTwoId); }
public RelationshipsController(RelationshipsRepository repo) { _repo = repo; }
public void ThenRelationshipsRepositoryAddRelationshipShouldHaveBeenCalled() => RelationshipsRepository.Verify(repository => repository.CreateRelationship(It.IsAny <Relationship>()), Times.Once);
public void ThenRelationshipsRepositoryGetRelationshipsByIdAndType() => RelationshipsRepository.Verify(repository => repository.GetRelationshipsByIdAndType( _userId, (RelationshipType)RelationshipTypeId), Times.Never);
public void ThenRelationshipsRepositoryGetRelationshipsByIdAndTypeShouldHaveBeenCalled() => RelationshipsRepository.Verify(repository => repository.GetRelationshipsByIdAndType( _userId, (RelationshipType)RelationshipTypeId), Times.Once);
public TripsController(TripsRepository repo, RelationshipsRepository relationshipsrepo, UsersRepository usersrepo) { _repo = repo; _relationshipsRepo = relationshipsrepo; _usersrepo = usersrepo; }
public void ThenRelationshipsRepositoryGetRelationshipByIdsAndTypeShouldHaveBeenCalled() => RelationshipsRepository.Verify( repository => repository.GetRelationshipByIdsAndType(_userOneId, _userTwoId, RelationshipType.Friend), Times.Once);
public void ThenRelationshipsRepositoryGetRelationshipByIdsAndType() => RelationshipsRepository.Verify( repository => repository.GetRelationshipByIdsAndType(_userOneId, _userTwoId, (RelationshipType)RelationshipTypeId), Times.Once);
public void ThenRelationshipsRepositoryGetRelationshipByIdsAndType() => RelationshipsRepository.Verify( repository => repository.GetRelationshipByIdsAndType(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <RelationshipType>()), Times.Never);