public void Properties_Map()
        {
            ApiResource model = new ApiResource
            {
                Description = "description",
                DisplayName = "displayname",
                Name        = "foo",
                Scopes      = { "foo1", "foo2" },
                Enabled     = false
            };

            Entities.ApiResource mappedEntity = model.ToEntity();

            mappedEntity.Scopes.Count.Should().Be(2);
            string foo1 = mappedEntity.Scopes.FirstOrDefault(x => x == "foo1");

            foo1.Should().NotBeNull();
            string foo2 = mappedEntity.Scopes.FirstOrDefault(x => x == "foo2");

            foo2.Should().NotBeNull();


            ApiResource mappedModel = mappedEntity.ToModel();

            mappedModel.Description.Should().Be("description");
            mappedModel.DisplayName.Should().Be("displayname");
            mappedModel.Enabled.Should().BeFalse();
            mappedModel.Name.Should().Be("foo");
        }
        public void Can_Map()
        {
            ApiResource model = new ApiResource();

            Entities.ApiResource mappedEntity = model.ToEntity();
            ApiResource          mappedModel  = mappedEntity.ToModel();

            Assert.NotNull(mappedModel);
            Assert.NotNull(mappedEntity);
        }
        public void missing_values_should_use_defaults()
        {
            Entities.ApiResource entity = new Entities.ApiResource {
                Secrets = new List <Secret> {
                    new Secret()
                }
            };

            ApiResource def = new ApiResource {
                ApiSecrets = { new Models.Secret("foo") }
            };

            ApiResource model = entity.ToModel();

            model.ApiSecrets.First().Type.Should().Be(def.ApiSecrets.First().Type);
        }
        public void ToModel_MapsAllowedIdentityTokenSigningAlgorithms()
        {
            var apiResource = new Entities.ApiResource()
            {
                AllowedAccessTokenSigningAlgorithms = "HS256,ES256"
            };

            var entity = apiResource.ToModel();

            Assert.NotNull(apiResource.AllowedAccessTokenSigningAlgorithms);
            Assert.NotEmpty(entity.AllowedAccessTokenSigningAlgorithms);

            var algorithms   = entity.AllowedAccessTokenSigningAlgorithms.ToList();
            var algorithmOne = algorithms[0];
            var algorithmTwo = algorithms[1];

            Assert.Equal("HS256", algorithmOne);
            Assert.Equal("ES256", algorithmTwo);
        }