Example #1
0
        public void AddIndexersConflict()
        {
            var cache = new Cache <V1Pod>();
            Dictionary <string, Func <V1Pod, List <string> > > initialIndexers = new Dictionary <string, Func <V1Pod, List <string> > >()
            {
                { "1", pod => new List <string>() },
                { "2", pod => new List <string>() },
            };
            Dictionary <string, Func <V1Pod, List <string> > > conflictIndexers = new Dictionary <string, Func <V1Pod, List <string> > >()
            {
                { "1", pod => new List <string>() },
            };

            cache.AddIndexers(initialIndexers);
            Assert.Throws <ArgumentException>(() => { cache.AddIndexers(conflictIndexers); });
        }
Example #2
0
        public void AddIndexersSuccess()
        {
            var cache = new Cache <V1Pod>();
            Dictionary <string, Func <V1Pod, List <string> > > indexers = new Dictionary <string, Func <V1Pod, List <string> > >()
            {
                { "2", pod => new List <string>()
                  {
                      pod.Name()
                  } },
                { "3", pod => new List <string>()
                  {
                      pod.Name()
                  } },
            };

            cache.AddIndexers(indexers);

            var savedIndexers = cache.GetIndexers();

            savedIndexers.Should().HaveCount(indexers.Count + 1); // blank cache constructor will add a default index
            savedIndexers.Should().Contain(indexers);

            // Todo: check indicies collection for new indexname keys
        }
Example #3
0
        public void AddNullIndexers()
        {
            var cache = new Cache <V1Pod>();

            Assert.Throws <ArgumentNullException>(() => { cache.AddIndexers(null); });
        }