当前位置: 首页>>代码示例>>C#>>正文


C# Mock.SetAdmin方法代码示例

本文整理汇总了C#中Mock.SetAdmin方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.SetAdmin方法的具体用法?C# Mock.SetAdmin怎么用?C# Mock.SetAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.SetAdmin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSeason_ValidPermissions_AddsAndSaves

        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>()));
        }
开发者ID:panzors,项目名称:TfsGamification,代码行数:11,代码来源:SeasonManagerTests.cs

示例2: AddAchievementToSeason_ValidAchievement_AddsAndSaves

        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());
        }
开发者ID:panzors,项目名称:TfsGamification,代码行数:16,代码来源:SeasonManagerTests.cs

示例3: CanModifySeason_InactiveSeason_ReturnsTrue

        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();
        }
开发者ID:panzors,项目名称:TfsGamification,代码行数:16,代码来源:SeasonManagerTests.cs

示例4: AddAchievementToSeason_Repeat_ThrowsExceptions

        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());
        }
开发者ID:panzors,项目名称:TfsGamification,代码行数:20,代码来源:SeasonManagerTests.cs


注:本文中的Mock.SetAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。