Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        public void ShouldCreateThemeFromDataBase()
        {
            using (var context = new DataInMemoryContext(MethodBase.GetCurrentMethod().Name))
            {
                var expectedTheme = new TopTenTheme
                {
                    Theme = "New Theme",
                };

                context.TopTenTheme.Add(expectedTheme);
                context.SaveChanges();

                var themeFromDataBase = context.TopTenTheme.FirstOrDefault();

                themeFromDataBase.Should().Be(expectedTheme);
            }
        }
Ejemplo n.º 3
0
        public void ShouldGetAllIdeeNotArchivedFromBoite()
        {
            var  boite = new BoiteAIdee();
            Idee newIdeeNotArchived = new Idee();
            Idee newIdeeArchived    = new Idee()
            {
                IsArchived = true,
            };

            List <Idee> expectedIdeesList = new List <Idee> {
                newIdeeNotArchived
            };

            using (var dbContext = new DataInMemoryContext(MethodBase.GetCurrentMethod().Name))
            {
                dbContext.Idee.Add(newIdeeArchived);
                dbContext.Idee.Add(newIdeeNotArchived);
                dbContext.SaveChanges();

                var ideesFromBoite = boite.GetAllIdees(dbContext).ToList();

                ideesFromBoite.Should().BeEquivalentTo(expectedIdeesList);
            }
        }
Ejemplo n.º 4
0
        public void ShouldGetThemeFromDataBase()
        {
            using (var context = new DataInMemoryContext(MethodBase.GetCurrentMethod().Name))
            {
                context.TopTenTheme.RemoveRange(context.TopTenTheme);

                var arrayOfThemes      = GetArrayOfThemes();
                var arrayOfTopTenTheme = arrayOfThemes.Select(t => new TopTenTheme {
                    Theme = t
                })
                                         .ToArray();
                context.TopTenTheme.AddRange(arrayOfTopTenTheme);
                context.SaveChanges();

                var themes = BotANick.Discord.Services.TopTenService.GetRandomThemes(context);

                arrayOfThemes.Should().BeEquivalentTo(themes);

                foreach (string theme in arrayOfThemes)
                {
                    theme.Should().BeOneOf(themes);
                }
            }
        }