Ejemplo n.º 1
0
        public async Task CreateSeason_ValidPermissions_AddsAndSaves()
        {
            Mock<IDbContext> fakeContext = new Mock<IDbContext>();
            fakeContext.SetAdmin(0);
            var seasonManager = new SeasonManager(fakeContext.Object, 0);

            var season = await seasonManager.CreateSeason();
            season.Should().NotBeNull();
            fakeContext.Verify(x => x.SaveChangesAsync());
            fakeContext.Verify(x => x.Add(It.IsAny<Season>()));
        }
Ejemplo n.º 2
0
        public async Task AddAchievementToSeason_ValidAchievement_AddsAndSaves()
        {
            Mock<IDbContext> fakeContext = new Mock<IDbContext>();
            fakeContext.SetAdmin(0);
            var season = new Season()
            {
                Id = 1,
                AchievementSeason = new List<SeasonalAchievement>(),
            };
            fakeContext.Setup(x => x.Get<Season>()).Returns(new Season[] { season }.AsQueryable());
            var seasonManager = new SeasonManager(fakeContext.Object, 0);

            await seasonManager.AddAchievementToSeason(1, 5, 0);

            fakeContext.Verify(x => x.SaveChangesAsync());
        }
Ejemplo n.º 3
0
        public void CanModifySeason_InactiveSeason_ReturnsTrue()
        {
            Mock<IDbContext> fakeContext = new Mock<IDbContext>();
            fakeContext.SetAdmin(0);
            fakeContext.Setup(x => x.Get<Season>()).Returns(new Season[]
            {
                new Season()
                {
                    Id = 1,
                }
            }.AsQueryable());
            var seasonManager = new SeasonManager(fakeContext.Object, 0);

            var result = seasonManager.CanModifySeason(1);
            result.Should().BeTrue();
        }
Ejemplo n.º 4
0
        public async Task AddAchievementToSeason_Repeat_ThrowsExceptions()
        {
            Mock<IDbContext> fakeContext = new Mock<IDbContext>();
            fakeContext.SetAdmin(0);
            var season = new Season()
            {
                Id = 1,
                AchievementSeason = new [] { new SeasonalAchievement
                {
                    SeasonId = 1,
                    AchievementId = 10,
                } },
            };
            fakeContext.Setup(x => x.Get<Season>()).Returns(new Season[] { season }.AsQueryable());
            var seasonManager = new SeasonManager(fakeContext.Object, 0);

            await seasonManager.AddAchievementToSeason(1, 10, 0);

            fakeContext.Verify(x => x.SaveChangesAsync(), Times.Never());
        }