Пример #1
0
		public void Add_Get_Simple()
		{
			//
			// TESTING SIMPLE Add/Get on default cache
			//
			// no regions
			//
			// Need to catch exception here to allow the program to run continously
			// Try this out
			// - Comment the try catch on this block of code
			// - Run this program twice within 10 mins
			// - Result, Add will throw a exception
			// - Run this program after 10 mins
			// - Result, Program will run ok
			// Try this out
			// - Put a VS-BreakPoint at the Get("KetToMyString") call
			// - Run the sample test after 10 mins
			// - Get will fail
			Console.WriteLine("----------------------");
			Console.WriteLine("Testing Simple Add/Get");
			Console.WriteLine("Cache       = default");
			Console.WriteLine("Region      = <none>");
			Console.WriteLine("Tags        = <none>");
			Console.WriteLine("Version     = <none>");
			try
			{
				if ((itemVersion = _defaultCache.Add("KeyToMyString", myObjectForCaching)) != null)
					Console.WriteLine("PASS--->Add-Object Added to Cache, HashCode: " + itemVersion.GetHashCode());
				else
					Console.WriteLine("**FAIL--->Add-Object did not add to cache - FAIL");

				if ((item = (string) _defaultCache.Get("KeyToMyString")) != null)
					Console.WriteLine("PASS--->Get-Object Get from cache");
				else
					Console.WriteLine("**FAIL--->Get-Object did not Get from cache");

				if ((item = (string) _defaultCache.Get("InCorrectKeySpecified")) == null)
					Console.WriteLine("PASS--->Get-Object did not Get, since invalid key specified");
				else
					Console.WriteLine("**FAIL--->Get-Object Get from cache, unexpected result");
			}
			catch (CacheException ex)
			{
				Console.WriteLine("**FAIL--->Add-Get-This is failing probably because you are running this");
				Console.WriteLine("          sample test within 10mins (default timeout) in clusterconfig.xml");
				Console.WriteLine("          To get this working, in the admin tool");
				Console.WriteLine("          - stop cluster");
				Console.WriteLine("          - delete cache default");
				Console.WriteLine("          - create cache default");
				Console.WriteLine("          - start cluster");
				Console.Write("**FAIL--->Distributed Cache Generated Exception:");
				Console.WriteLine(ex.Message);
			}
		}
Пример #2
0
        public void Add_Get_Simple()
        {
            //
            // TESTING SIMPLE Add/Get on default cache
            //
            // no regions
            //
            // Need to catch exception here to allow the program to run continously
            // Try this out
            // - Comment the try catch on this block of code
            // - Run this program twice within 10 mins
            // - Result, Add will throw a exception
            // - Run this program after 10 mins
            // - Result, Program will run ok
            // Try this out
            // - Put a VS-BreakPoint at the Get("KetToMyString") call
            // - Run the sample test after 10 mins
            // - Get will fail
            Console.WriteLine("----------------------");
            Console.WriteLine("Testing Simple Add/Get");
            Console.WriteLine("Cache       = default");
            Console.WriteLine("Region      = <none>");
            Console.WriteLine("Tags        = <none>");
            Console.WriteLine("Version     = <none>");
            try
            {
                if ((itemVersion = _defaultCache.Add("KeyToMyString", myObjectForCaching)) != null)
                {
                    Console.WriteLine("PASS--->Add-Object Added to Cache, HashCode: " + itemVersion.GetHashCode());
                }
                else
                {
                    Console.WriteLine("**FAIL--->Add-Object did not add to cache - FAIL");
                }

                if ((item = (string)_defaultCache.Get("KeyToMyString")) != null)
                {
                    Console.WriteLine("PASS--->Get-Object Get from cache");
                }
                else
                {
                    Console.WriteLine("**FAIL--->Get-Object did not Get from cache");
                }

                if ((item = (string)_defaultCache.Get("InCorrectKeySpecified")) == null)
                {
                    Console.WriteLine("PASS--->Get-Object did not Get, since invalid key specified");
                }
                else
                {
                    Console.WriteLine("**FAIL--->Get-Object Get from cache, unexpected result");
                }
            }
            catch (CacheException ex)
            {
                Console.WriteLine("**FAIL--->Add-Get-This is failing probably because you are running this");
                Console.WriteLine("          sample test within 10mins (default timeout) in clusterconfig.xml");
                Console.WriteLine("          To get this working, in the admin tool");
                Console.WriteLine("          - stop cluster");
                Console.WriteLine("          - delete cache default");
                Console.WriteLine("          - create cache default");
                Console.WriteLine("          - start cluster");
                Console.Write("**FAIL--->Distributed Cache Generated Exception:");
                Console.WriteLine(ex.Message);
            }
        }