public void Test()
        {
            var scoping = Scoping.Parse(null);

            Assert.Equal(0, scoping.Count);
            Assert.True(string.IsNullOrEmpty(scoping.ToString()));

            scoping.Include("UserId");
            Assert.Equal(1, scoping.Count);

            scoping.Add("*, !CreatedTime");
            Assert.Equal(3, scoping.Count);

            scoping.Add("CreatedTime");
            Assert.Equal(3, scoping.Count);

            scoping.Add("!");
            Assert.Equal(1, scoping.Count);

            var members = scoping.ToArray();

            Assert.Equal(1, members.Length);
            Assert.Equal("!", members[0]);

            members = scoping.ToArray(wildcard => this.GetEntityProperties());
            Assert.Equal(0, members.Length);

            scoping.Add("*, !CreatorId, ! createdTime");
            members = scoping.ToArray(wildcard => this.GetEntityProperties());
            Assert.True(members.Length > 1);
            Assert.True(Array.Exists(members, item => string.Equals(item, "AssetId", StringComparison.OrdinalIgnoreCase)));
            Assert.False(Array.Exists(members, item => string.Equals(item, "CreatorId", StringComparison.OrdinalIgnoreCase)));
            Assert.False(Array.Exists(members, item => string.Equals(item, "CreatedTime", StringComparison.OrdinalIgnoreCase)));
        }
Exemplo n.º 2
0
        public static Scoping Parse(string text)
        {
            var scoping = new Scoping(null);

            scoping.Add(text);
            return(scoping);
        }
Exemplo n.º 3
0
        public static Scoping Parse(string text)
        {
            var scoping = new Scoping();

            if (!string.IsNullOrWhiteSpace(text))
            {
                scoping.AddCore(text.Split(','));
            }

            return(scoping);
        }
Exemplo n.º 4
0
        public void Test()
        {
            var scoping = Scoping.Parse(null);

            Assert.Equal(0, scoping.Count);
            Assert.True(string.IsNullOrEmpty(scoping.ToString()));

            scoping.Include("UserId");
            Assert.Equal(1, scoping.Count);

            scoping.Add("*, !CreatedTime");
            Assert.Equal(3, scoping.Count);

            scoping.Add("CreatedTime");
            Assert.Equal(3, scoping.Count);

            scoping.Add("!");
            Assert.Equal(0, scoping.Count);

            var members = scoping.Map();

            Assert.Equal(0, members.Count());

            members = scoping.Map(wildcard => this.GetEntityProperties());
            Assert.Equal(0, members.Count());

            scoping.Add("*, !CreatorId, !createdtime");
            members = scoping.Map(wildcard => this.GetEntityProperties());
            Assert.True(members.Count() > 1);
            Assert.True(members.Contains("AssetId"));
            Assert.False(members.Contains("CreatorId"));
            Assert.False(members.Contains("CreatedTime"));

            Assert.True(scoping.Count > 1);
            scoping.Add("!");
            Assert.Equal(0, scoping.Count);
        }