static void InsertTestData(ConsentStore store, int count = 1)
 {
     for (int i = 0; i < count; ++i)
     {
         for (int sub = 0; sub < 10; ++sub)
         {
             Consent consent = new Consent()
             {
                 ClientId = "CLIENTID:" + i, Scopes = new List <string>()
                 {
                     "a", "b"
                 }, Subject = "SUBJECT:" + sub
             };
             ConsentRecord consentRecord = new ConsentRecord(new ConsentHandle(consent));
             store.CreateAsync(consentRecord.Record);
         }
     }
 }
Ejemplo n.º 2
0
        public Enrollee ToModel(IDictionary <long, PlanEntry> plansDict)
        {
            Enrollee enrollee = new Enrollee()
            {
                Id            = Id,
                FullName      = FullName,
                Year          = Year,
                KindPrivilege = KindPrivilege,
                Doc           = Doc,
                Status        = Status,
                EnrolledTo    = FinTypes.SingleOrDefault(f => f.Enrolled)?.PlanId ?? 0,
                ApprovedTo    = ConsentRecord?.ToModel()
            };

            enrollee.Plans = Plans.Select(p => p.ToModel(plansDict[p.PlanId], FinTypes.Where(f => f.PlanId == p.PlanId), enrollee)).ToArray();
            enrollee.Exams = Marks.Select(m => m.ToModel()).ToArray();

            return(enrollee);
        }
        public void TestCreateAsync()
        {
            string testData = System.IO.File.ReadAllText(Path.Combine(TargetFolder, @"clients.json"));

            Consent consent = new Consent()
            {
                ClientId = "CLIENTID", Scopes = new List <string>()
                {
                    "a", "b"
                }, Subject = "SUBJECT"
            };
            ConsentRecord consentRecord = new ConsentRecord(new ConsentHandle(consent));

            _consentStore.CreateAsync(consentRecord.Record);

            var           result = _consentStore.LoadAsync(consent.Subject, consent.ClientId);
            ConsentRecord consentRecordStored = new ConsentRecord(new ConsentHandle(result.Result));


            Assert.AreEqual(consentRecord.Id, consentRecordStored.Id);
        }
        public void TestUpdateAsync()
        {
            Consent consent = new Consent()
            {
                ClientId = "CLIENTID", Scopes = new List <string>()
                {
                    "a", "b"
                }, Subject = "SUBJECT"
            };
            ConsentRecord consentRecord = new ConsentRecord(new ConsentHandle(consent));

            _consentStore.CreateAsync(consentRecord.Record);

            var           result = _consentStore.LoadAsync(consentRecord.Record.Subject, consentRecord.Record.ClientId);
            ConsentRecord consentRecordStored = new ConsentRecord(new ConsentHandle(result.Result));


            Assert.AreEqual(consentRecord.Id, consentRecordStored.Id);

            consentRecord.Record.Scopes = new List <string>()
            {
                "c", "d"
            };
            _consentStore.UpdateAsync(consentRecord.Record);
            result = _consentStore.LoadAsync(consentRecord.Record.Subject, consentRecord.Record.ClientId);
            consentRecordStored = new ConsentRecord(new ConsentHandle(result.Result));


            Assert.AreEqual(consentRecord.Id, consentRecordStored.Id);

            var query = from item in consentRecordStored.Record.Scopes
                        where item == "c"
                        select item;

            Assert.IsTrue(query.Any());
        }