public async Task ProfileNotFriendsShouldBeNotAllowedToAccess()
        {
            Profile profile    = GetNewProfile(Guid.NewGuid());
            Profile profileTwo = GetNewProfile(Guid.NewGuid());

            ProfileDomainService profileDomainService = new ProfileDomainService(GetSimpleProfileRepository(profile, profileTwo));
            ProfileAccessResult  accessResult         = await profileDomainService.CanAccessProfileData(profile.Id, profileTwo.Id);

            Assert.AreEqual(ProfileAccessResult.Forbidden, accessResult);
        }
        public async Task ShouldMakeUsersFriends()
        {
            Profile profile    = GetNewProfile(Guid.NewGuid());
            Profile profileTwo = GetNewProfile(Guid.NewGuid());

            ProfileDomainService profileDomainService = new ProfileDomainService(GetSimpleProfileRepository(profile, profileTwo));
            CommandResult        commandResult        = await profileDomainService.MakeFriends(profile.Id, profileTwo.Id);

            Assert.IsTrue(commandResult.Success);
            Assert.AreEqual(1, profile.Friends.Count);
            Assert.AreEqual(1, profileTwo.Friends.Count);
        }
        public async Task ShouldNotFindProfileInRepository()
        {
            Mock <IProfileRepository> mock = new Mock <IProfileRepository>();

            mock.Setup(repo => repo.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(() => null);

            ProfileDomainService profileDomainService = new ProfileDomainService(mock.Object);
            ProfileAccessResult  accessResult         = await profileDomainService.CanAccessProfileData(Guid.NewGuid(), Guid.NewGuid());

            Assert.AreEqual(ProfileAccessResult.NotFound, accessResult);
        }
        public async Task ProfileOwnerShouldBeAllowedToAccessData()
        {
            Mock <IProfileRepository> mock = new Mock <IProfileRepository>();
            Profile profile = GetNewProfile();

            mock.Setup(repo => repo.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(profile);

            ProfileDomainService profileDomainService = new ProfileDomainService(mock.Object);
            ProfileAccessResult  accessResult         = await profileDomainService.CanAccessProfileData(profile.Id, profile.Id);

            Assert.AreEqual(ProfileAccessResult.CanAccess, accessResult);
        }
        public async Task ShouldFailToFindUserIdsEndFriendship()
        {
            Mock <IProfileRepository> mock = new Mock <IProfileRepository>();

            mock.Setup(repo => repo.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(() => null);

            ProfileDomainService profileDomainService = new ProfileDomainService(mock.Object);
            CommandResult        commandResult        = await profileDomainService.EndFriendship(Guid.NewGuid(), Guid.NewGuid());

            Assert.IsFalse(commandResult.Success);
            Assert.AreEqual("Ocorreu um erro ao buscar os perfis envolvidos na operação.", commandResult.Notifications.FirstOrDefault().Description);
        }
        public async Task ProfileFriendsShouldBeAllowedToAccess()
        {
            Profile profile    = GetNewProfile(Guid.NewGuid());
            Profile profileTwo = GetNewProfile(Guid.NewGuid());

            profileTwo.ChangeSettings(new ProfileSettings(PrivacyType.Protected));

            profile.AddFriend(profileTwo);
            profileTwo.AddFriend(profile);

            ProfileDomainService profileDomainService = new ProfileDomainService(GetSimpleProfileRepository(profile, profileTwo));
            ProfileAccessResult  accessResult         = await profileDomainService.CanAccessProfileData(profile.Id, profileTwo.Id);

            Assert.AreEqual(ProfileAccessResult.CanAccess, accessResult);
        }
        public async Task ShouldFailToEndUserFriendWithHimself()
        {
            Profile profile = GetNewProfile();

            Mock <IProfileRepository> mock = new Mock <IProfileRepository>();

            mock.Setup(repo => repo.GetByIdAsync(It.IsAny <Guid>()))
            .ReturnsAsync(profile);

            ProfileDomainService profileDomainService = new ProfileDomainService(mock.Object);
            CommandResult        commandResult        = await profileDomainService.EndFriendship(profile.Id, profile.Id);

            Assert.IsFalse(commandResult.Success);
            Assert.AreEqual("Não é possível tornar-se amigo de si mesmo.", commandResult.Notifications.FirstOrDefault().Description);
        }
        public async Task ShouldFailToMakeUsersFriendsTwoTimes()
        {
            Profile profile    = GetNewProfile(Guid.NewGuid());
            Profile profileTwo = GetNewProfile(Guid.NewGuid());

            ProfileDomainService profileDomainService = new ProfileDomainService(GetSimpleProfileRepository(profile, profileTwo));
            CommandResult        commandResult        = await profileDomainService.MakeFriends(profile.Id, profileTwo.Id);

            Assert.IsTrue(commandResult.Success);
            Assert.AreEqual(1, profile.Friends.Count);
            Assert.AreEqual(1, profileTwo.Friends.Count);

            CommandResult secondCommandResult = await profileDomainService.MakeFriends(profile.Id, profileTwo.Id);

            Assert.IsFalse(secondCommandResult.Success);
            Assert.AreEqual("Você e esse usuário já são amigos.", secondCommandResult.Notifications.FirstOrDefault().Description);
        }
        public async Task ShouldFailToEndUsersFriendshipTwoTimes()
        {
            Profile profile    = GetNewProfile(Guid.NewGuid());
            Profile profileTwo = GetNewProfile(Guid.NewGuid());

            ProfileDomainService profileDomainService = new ProfileDomainService(GetSimpleProfileRepository(profile, profileTwo));
            CommandResult        friendsResult        = await profileDomainService.MakeFriends(profile.Id, profileTwo.Id);

            Assert.IsTrue(friendsResult.Success);
            Assert.AreEqual(1, profile.Friends.Count);
            Assert.AreEqual(1, profileTwo.Friends.Count);

            CommandResult unfriendsResult = await profileDomainService.EndFriendship(profile.Id, profileTwo.Id);

            Assert.IsTrue(unfriendsResult.Success);
            Assert.AreEqual(0, profile.Friends.Count);
            Assert.AreEqual(0, profileTwo.Friends.Count);

            CommandResult unfriendsResultTwo = await profileDomainService.EndFriendship(profile.Id, profileTwo.Id);

            Assert.IsFalse(unfriendsResultTwo.Success);
            Assert.AreEqual("Você e esse usuário ainda não são amigos.", unfriendsResultTwo.Notifications.FirstOrDefault().Description);
        }