本文整理汇总了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>()));
}
示例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());
}
示例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();
}
示例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());
}