system-praktyk-api/test/InternshipSystem.Api.Test/InternshipSystem.cs

60 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Text.Json;
using InternshipSystem.Api.Controllers;
using Machine.Specifications;
namespace InternshipSystem.Api.Test
{
[Subject(typeof(JsonSerializer))]
class When_deserializing_cas
{
private static string json;
private Establish context = () =>
{
// {
// "service": "https://system-praktyk.stg.kadet.net/user/login/code",
// "attributes": {
// "albumNumber": "165581",
// "firstName": "Kacper",
// "lastName": "Donat",
// "mail": [
// "kacdonat@pg.edu.pl",
// "kacper.donat@pg.edu.pl",
// "s165581@student.pg.edu.pl"
// ],
// "personNumber": "1101074",
// "PG_CUI_PORTALROLES": [
// "ROLE_EKONTAKT_PROD",
// "RP_STUDENT",
// "RP_USER",
// "ROLE_TRAC",
// "ROLE_HUDSON",
// "ROLE_WWW_ADMIN",
// "RP_PRACOWNIK"
// ]
// },
// "id": "1101074",
// "client_id": "PraktykiClientId"
// }
json =
" {\r\n \"service\": \"https://system-praktyk.stg.kadet.net/user/login/code\",\r\n \"attributes\": {\r\n \"albumNumber\": \"165581\",\r\n \"firstName\": \"Kacper\",\r\n \"lastName\": \"Donat\",\r\n \"mail\": [\r\n \"kacdonat@pg.edu.pl\",\r\n \"kacper.donat@pg.edu.pl\",\r\n \"s165581@student.pg.edu.pl\"\r\n ],\r\n \"personNumber\": \"1101074\",\r\n \"PG_CUI_PORTALROLES\": [\r\n \"ROLE_EKONTAKT_PROD\",\r\n \"RP_STUDENT\",\r\n \"RP_USER\",\r\n \"ROLE_TRAC\",\r\n \"ROLE_HUDSON\",\r\n \"ROLE_WWW_ADMIN\",\r\n \"RP_PRACOWNIK\"\r\n ]\r\n },\r\n \"id\": \"1101074\",\r\n \"client_id\": \"PraktykiClientId\"\r\n }";
options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
};
};
private Because of = () => result = JsonSerializer.Deserialize<CasUserProfile>(json, options);
private It should_nop = () => true.ShouldBeTrue();
private static JsonSerializerOptions options;
private static CasUserProfile result;
}
}