Exemplo n.º 1
0
        public void Get_returns_existing_item_from_id()
        {
            // arrange
            LookupCache <AccessLevel> target;
            AccessLevel expected;
            AccessLevel actual;
            Dictionary <int, AccessLevel> dict;

            target = new LookupCache <AccessLevel>(null);

            dict = (Dictionary <int, AccessLevel>)target.GetType().GetField("_cache", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(target);

            expected = new AccessLevel
            {
                Id    = 90,
                Name  = "alpha",
                Label = "beta"
            };

            dict.Add(expected.Id, expected);

            // act
            actual = target.Get(expected.Id);

            // assert
            Assert.AreSame(expected, actual);
        }