Exemplo n.º 1
0
 public RecommendationsController(RecommendationsRepository repo, RecPhotosRepository photosrepo, RelationshipsRepository relationshipsrepo, UsersRepository usersrepo)
 {
     _repo              = repo;
     _photosRepo        = photosrepo;
     _relationshipsRepo = relationshipsrepo;
     _usersrepo         = usersrepo;
 }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
            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);
            }
Exemplo n.º 5
0
            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);
            }
Exemplo n.º 6
0
            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);
            }
Exemplo n.º 7
0
 public RelationshipsController(RelationshipsRepository repo)
 {
     _repo = repo;
 }
Exemplo n.º 8
0
 public void ThenRelationshipsRepositoryAddRelationshipShouldHaveBeenCalled()
 => RelationshipsRepository.Verify(repository => repository.CreateRelationship(It.IsAny <Relationship>()), Times.Once);
Exemplo n.º 9
0
 public void ThenRelationshipsRepositoryGetRelationshipsByIdAndType()
 => RelationshipsRepository.Verify(repository => repository.GetRelationshipsByIdAndType(
                                       _userId, (RelationshipType)RelationshipTypeId), Times.Never);
Exemplo n.º 10
0
 public void ThenRelationshipsRepositoryGetRelationshipsByIdAndTypeShouldHaveBeenCalled()
 => RelationshipsRepository.Verify(repository => repository.GetRelationshipsByIdAndType(
                                       _userId, (RelationshipType)RelationshipTypeId), Times.Once);
Exemplo n.º 11
0
 public TripsController(TripsRepository repo, RelationshipsRepository relationshipsrepo, UsersRepository usersrepo)
 {
     _repo = repo;
     _relationshipsRepo = relationshipsrepo;
     _usersrepo         = usersrepo;
 }
Exemplo n.º 12
0
 public void ThenRelationshipsRepositoryGetRelationshipByIdsAndTypeShouldHaveBeenCalled()
 => RelationshipsRepository.Verify(
     repository =>
     repository.GetRelationshipByIdsAndType(_userOneId, _userTwoId, RelationshipType.Friend),
     Times.Once);
Exemplo n.º 13
0
 public void ThenRelationshipsRepositoryGetRelationshipByIdsAndType()
 => RelationshipsRepository.Verify(
     repository =>
     repository.GetRelationshipByIdsAndType(_userOneId, _userTwoId,
                                            (RelationshipType)RelationshipTypeId), Times.Once);
Exemplo n.º 14
0
 public void ThenRelationshipsRepositoryGetRelationshipByIdsAndType()
 => RelationshipsRepository.Verify(
     repository =>
     repository.GetRelationshipByIdsAndType(It.IsAny <Guid>(), It.IsAny <Guid>(), It.IsAny <RelationshipType>()),
     Times.Never);