public async Task WhenUserValid_OK()
        {
            using var app    = _webApplicationFactory.CreateApp();
            using var client = _webApplicationFactory.CreateClient();

            await client.ImpersonateUserAsync(app.SeededEntities.TestUserArea2.RoleA.User);

            var result = await client.GetAsync(GetRoute("user-area"));

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
        public async Task WhenNoChange_Validates()
        {
            var seedDate        = DateTimeOffset.UtcNow;
            var dateTimeService = new MockDateTimeService(seedDate);

            using var app    = _webApplicationFactory.CreateApp();
            using var client = _webApplicationFactory.CreateClientWithServices(s => s.AddSingleton <IDateTimeService>(dateTimeService));
            var user = app.SeededEntities.TestUserArea1.RoleA.User;

            await client.ImpersonateUserAsync(user);

            dateTimeService.MockDateTime = seedDate.AddMinutes(35);
            var userId = await GetCurrentlySignedInUserId(client);

            userId.Should().Be(user.UserId);
        }
        public async Task PermissionOnAnonymousRole_WhenNotSignedIn_OK()
        {
            using var app    = _webApplicationFactory.CreateApp();
            using var client = _webApplicationFactory.CreateClient();

            var result = await client.GetAsync(GetRoute("permission-on-anonymous-role"));

            result.StatusCode.Should().Be(HttpStatusCode.OK);
        }
Пример #4
0
        public async Task WhenCustomEntityPageNotExists_Returns404()
        {
            using var client = _webApplicationFactory.CreateClient();
            using var app    = _webApplicationFactory.CreateApp();

            var page   = app.SeededEntities.TestDirectory.CustomEntityPage;
            var result = await client.GetAsync(page.GetFullPath(Int32.MaxValue));

            var content = await result.Content.ReadAsStringAsync();

            result.StatusCode.Should().Be(HttpStatusCode.NotFound);
            content.Should().Match("*Page not found*");
        }