public static void UpdateArchive(this Idee idee) { if (idee.HasToBeArchived()) { idee.Archive(); } }
public static void SetNbVotesBasedOnEmotes(this Idee idee, IReadOnlyDictionary<IEmote, ReactionMetadata> reactions) { var ideeContext = new BoiteAIdee(); var reaction = reactions.FirstOrDefault(r => r.Key.Name == ideeContext.EmoteUpVote.Name); idee.SetNbVote(reaction.Value.ReactionCount); }
public void ShouldSetEtatFaite() { var idee = new Idee(); idee.SetEtatFaite(); idee.EtatIdee.Should().Be(EtatsIdees.Faite); }
public void ShouldSetEtatRejetee() { var idee = new Idee(); idee.SetEtatRejetee(); idee.EtatIdee.Should().Be(EtatsIdees.Rejetee); }
public void ShouldSetEtatRejeteeMarkAsModified() { var idee = new Idee(); idee.SetEtatRejetee(); idee.IsModified().Should().BeTrue(); }
public void ShouldCreateBuilderFromIdee() { var idee = new Idee(); var builder = idee.GetBuilder(); builder.ToStringCustom().Should().Be(_expectedBuilder); }
public void ShouldSetEtatEnCoursMarkAsModified() { var idee = new Idee(); idee.SetEtatEnCours(); idee.IsModified().Should().BeTrue(); }
public void ShouldSetEtatEnCours() { var idee = new Idee(); idee.SetEtatEnCours(); idee.EtatIdee.Should().Be(EtatsIdees.EnCours); }
public void ShouldUpdateNbVote() { var idee = new Idee(); const int expectedNbVote = 1; idee.SetNbVote(expectedNbVote); idee.NombreVotes.Should().Be(expectedNbVote); }
private static void UpdateNombreVoteIdee(this Idee idee, IMessage messageIdee) { if (idee.IdMsgDiscord == null) { return; } idee.SetNbVotesBasedOnEmotes(messageIdee.Reactions); }
public void ShouldUpdateIdMsgDiscord() { var idee = new Idee(); const int expectedIdMsgDiscord = 0; idee.SetIdMsgDiscord(expectedIdMsgDiscord); idee.IdMsgDiscord.Should().Be(expectedIdMsgDiscord); }
public void ShouldUpdateNbVoteMarkAsModified() { var idee = new Idee(); const int expectedNbVote = 1; idee.SetNbVote(expectedNbVote); idee.IsModified().Should().BeTrue(); }
private static void SetEtat(this Idee idee, EtatsIdees newEtat) { if (idee.EtatIdee == newEtat) { return; } idee.EtatIdee = newEtat; idee.Modify(); }
public void ShouldArchiveIdee() { var idee = new Idee(); idee.IsArchived.Should().BeFalse(); idee.Archive(); idee.IsArchived.Should().BeTrue(); }
private static void UpdateEtatIdee(this Idee idee, IMessage messageIdee) { if (idee.IdMsgDiscord == null) { return; } var emotes = messageIdee.Reactions.Select(r => r.Key).ToList(); idee.SetEtatBasedOnEmotes(emotes); }
public static void SetNbVote(this Idee idee, int newNbVotes) { if (idee.NombreVotes == newNbVotes) { return; } idee.NombreVotes = newNbVotes; idee.Modify(); }
public static void UpdateIdee(this Idee idee, IMessage msgIdee) { if (msgIdee?.Id != idee.IdMsgDiscord) { return; } idee.UpdateNombreVoteIdee(msgIdee); idee.UpdateEtatIdee(msgIdee); idee.UpdateArchive(); }
public void ShouldSetSameEtatNotMarkAsModified() { var idee = new Idee { EtatIdee = EtatsIdees.EnCours, }; idee.SetEtatEnCours(); idee.IsModified().Should().BeFalse(); }
public static async Task <ulong> ShowIdeeInBoite(Idee idee) { var boiteChannel = _discord.GetChannel(_boiteAIdee.IdBoiteChannel) as SocketTextChannel; var builder = idee.GetBuilder(); var msg = await MessageService.WriteInChannel(boiteChannel, builder); await msg.AddReactionAsync(_boiteAIdee.EmoteUpVote); return(msg.Id); }
public void ShouldHaveInheritedProperties() { var idee = new Idee(); idee.IdeeId.Should().Be(_defaultIdeeId); idee.Description.Should().Be(_defaultDescription); idee.DateCreation.Should().Be(_defaultDateCreation); idee.EtatIdee.Should().Be(_defaultEtatIdee); idee.NombreVotes.Should().Be(_defaultNombreVotes); idee.Createur.Should().Be(_defaultCreateurName); idee.IdMsgDiscord.Should().Be(_defaultIdMsgDiscord); }
public void ShouldUpdateSameNbVoteNotMarkAsModified() { const int expectedNbVote = 1; var idee = new Idee { NombreVotes = expectedNbVote, }; idee.SetNbVote(expectedNbVote); idee.IsModified().Should().BeFalse(); }
public void ShouldClearIdMsgDiscord() { const int initialIdMsgDiscord = 0; ulong? expectedIdMsgDiscord = null; var idee = new Idee() { IdMsgDiscord = initialIdMsgDiscord, }; idee.ClearIdMsgDiscord(); idee.IdMsgDiscord.Should().Be(expectedIdMsgDiscord); }
public static Idee AddIdeeInDbContext(IDataContext dbContext, string description, string creator) { var idee = new Idee { Createur = creator, DateCreation = DateTime.Now, Description = description, EtatIdee = EtatsIdees.Soumise, }; dbContext.Idee.Add(idee); return idee; }
private static async Task UpdateDiscordMessage(Idee idee, IMessage msgIdee) { if (idee.IsArchived && msgIdee is IUserMessage msgToDelete) { await msgToDelete.DeleteAsync(); idee.ClearIdMsgDiscord(); } else if (idee.IsModified() && msgIdee is IUserMessage msgToUpdate) { await msgToUpdate.ModifyAsync(m => { m.Embed = idee.GetBuilder().Build(); }); } }
public void ShouldSetEtatEnCoursBasedOnEmote() { var idee = new Idee(); var ideeContext = new BoiteAIdee(); var emotes = new List <IEmote> { ideeContext.EmoteEtatEnCours }; idee.SetEtatBasedOnEmotes(emotes); idee.EtatIdee.Should().Be(EtatsIdees.EnCours); }
public void ShouldSetEtatTermineeBasedOnEmote() { var idee = new Idee(); var ideeContext = new BoiteAIdee(); var emotes = new List <IEmote> { ideeContext.EmoteEtatTermine }; idee.SetEtatBasedOnEmotes(emotes); idee.EtatIdee.Should().Be(EtatsIdees.Faite); }
public async Task ShouldGitHubIdeeHaveLabel() { BotANick.Discord.Program.Main(new string[] { }); var gitHubService = new GitHubService(); var expectedLabel = await gitHubService.Client.Issue.Labels.Get("kitarsh", "botanick", "Idee"); Idee idee = new Idee(); var createdIssue = await gitHubService.AddIssueBasedOnIdee(idee); var issue = await gitHubService.GetLastIssue(); issue.Labels.Select(l => l.Id).Should().Contain(expectedLabel.Id); await ClearIssue(gitHubService, createdIssue); }
public void ShouldIdeeHasToBeArchived() { var ideeRejetee = new Idee() { EtatIdee = EtatsIdees.Rejetee, }; var ideeFaite = new Idee() { EtatIdee = EtatsIdees.Faite, }; ideeRejetee.HasToBeArchived().Should().BeTrue(); ideeFaite.HasToBeArchived().Should().BeTrue(); }
public void ShouldIdeeNotHasToBeArchived() { var ideeEnCours = new Idee() { EtatIdee = EtatsIdees.EnCours, }; var ideeSoumis = new Idee() { EtatIdee = EtatsIdees.Soumise, }; ideeEnCours.HasToBeArchived().Should().BeFalse(); ideeSoumis.HasToBeArchived().Should().BeFalse(); }
public void ShouldCreateIdeeFromMessage() { const string _expectedDescription = "This is the description."; const string _expectedCreatorName = "Creator's Name"; string expectedIdeeString = $"1, Creator's Name, {DateTime.Now.Date}, This is the description., Soumise, , 0"; using (var dbContext = new DataInMemoryContext(MethodBase.GetCurrentMethod().Name)) { Idee newIdee = null; newIdee = IdeeExtension.AddIdeeInDbContext(dbContext, _expectedDescription, _expectedCreatorName); dbContext.SaveChanges(); var expectedIdee = dbContext.Idee.FirstOrDefault(i => i.IdeeId == newIdee.IdeeId); expectedIdee.ToStringCustom().Should().Be(expectedIdeeString); } }