public async Task WhenFoundBySuperUser_ReturnsCorrespondingObjectIrrespectiveOfProtectKey() { var user = new ClaimsPrincipal(); var identity = new ClaimsIdentity(); identity.AddClaim(new Claim(identity.RoleClaimType, nameof(Role.SuperUser))); user.AddIdentity(identity); var sut = CreateSut(out var repository, out var mapper, "1", user); var sentinelEntry = new SentinelEntry { ProtectKey = "12" }; var sentinelEntryResponse = new SentinelEntryResponse { }; repository.FirstOrDefaultAsync(Arg.Is <SentinelEntryIncludingTestsSpecification>(specification => specification.Id == 567)) .Returns(Task.FromResult(sentinelEntry)); mapper.Map <SentinelEntryResponse>(sentinelEntry).Returns(sentinelEntryResponse); var action = await sut.HandleAsync(567).ConfigureAwait(true); var okResult = action.Result.Should().BeOfType <OkObjectResult>().Subject; okResult.Value.Should().Be(sentinelEntryResponse); }
protected override async Task OnInitializedAsync() { Logger.LogInformation("Now loading... /SentinelEntries/Details/{Id}", Id); SentinelEntry = await SentinelEntryService.GetById(Id).ConfigureAwait(true); await base.OnInitializedAsync().ConfigureAwait(true); }
public async Task WhenFound_ReturnsCorrespondingObject() { var sut = CreateSut(out var repository, out var mapper, "12"); var sentinelEntry = new SentinelEntry { ProtectKey = "12" }; var sentinelEntryResponse = new SentinelEntryResponse { }; repository.FirstOrDefaultAsync(Arg.Is <SentinelEntryIncludingTestsSpecification>(specification => specification.Id == 567)) .Returns(Task.FromResult(sentinelEntry)); mapper.Map <SentinelEntryResponse>(sentinelEntry).Returns(sentinelEntryResponse); var action = await sut.HandleAsync(567).ConfigureAwait(true); var okResult = action.Result.Should().BeOfType <OkObjectResult>().Subject; okResult.Value.Should().Be(sentinelEntryResponse); }