コード例 #1
0
 public void GetOrCreate_GivenParameterAgain_ReturnsItemPreviouslyCreatedFromTheParameter()
 {
     int createdItemCount = 0;
     var test = new FactoryCachingDictionary<string, int>(x => ++createdItemCount);
     Assert.Equal(1, test.GetOrCreate("First item"));
     Assert.Equal(2, test.GetOrCreate("Second item"));
     Assert.Equal(1, test.GetOrCreate("First item"));
 }
コード例 #2
0
        public void GetOrCreate_GivenParameterAgain_ReturnsItemPreviouslyCreatedFromTheParameter()
        {
            int createdItemCount = 0;
            var test             = new FactoryCachingDictionary <string, int>(x => ++ createdItemCount);

            Assert.Equal(1, test.GetOrCreate("First item"));
            Assert.Equal(2, test.GetOrCreate("Second item"));
            Assert.Equal(1, test.GetOrCreate("First item"));
        }
コード例 #3
0
        public void GetOrCreate_GivenParameter_ReturnsItemCreatedWithParameter()
        {
            var test = new FactoryCachingDictionary <int, string>(x => x.ToString());

            Assert.Equal("6", test.GetOrCreate(6));
        }
コード例 #4
0
 public void GetOrCreate_GivenParameter_ReturnsItemCreatedWithParameter()
 {
     var test = new FactoryCachingDictionary<int, string>(x => x.ToString());
     Assert.Equal("6", test.GetOrCreate(6));
 }