public void TestExceptionsWithHttpContext()
        {
            HttpContext context = new HttpContext(new HttpRequest(null,"http://google.com",null), new HttpResponse(Console.Out));
            HttpContext.Current = context;
            CacheTestClass foo = new CacheTestClass();
            foo.resetCaching();
            Exception first = null;
            try
            {
                Console.WriteLine(String.IsNullOrEmpty(foo.ThrowExceptionWithCache()));
            }
            catch (Exception e)
            {
                first = e;
                Console.WriteLine(first.ToString());
            }

            Exception second = null;
            try
            {
                Console.WriteLine(String.IsNullOrEmpty(foo.ThrowExceptionWithoutCache()));
            }
            catch (Exception e)
            {
                second = e;
                Console.WriteLine(second.ToString());
            }

            Assert.IsNotNull(first, "First is null");
            Assert.IsNotNull(second, "Second is null");
            Assert.AreEqual(first.Message, second.Message, "First message and second message are different, but not null");
        }
Beispiel #2
0
        public void TestExceptionsWithouthHttpContext()
        {
            HttpContext.Current = null;
            CacheTestClass foo = new CacheTestClass();

            foo.resetCaching();
            Exception first = null;

            try
            {
                Console.WriteLine(String.IsNullOrEmpty(foo.ThrowExceptionWithCache()));
            }
            catch (Exception e)
            {
                first = e;
                Console.WriteLine(first.ToString());
            }

            Exception second = null;

            try
            {
                Console.WriteLine(String.IsNullOrEmpty(foo.ThrowExceptionWithoutCache()));
            }
            catch (Exception e)
            {
                second = e;
                Console.WriteLine(second.ToString());
            }

            Assert.IsNotNull(first, "First is null");
            Assert.IsNotNull(second, "Second is null");
            Assert.AreEqual(first.Message, second.Message, "First message and second message are different, but not null");
        }
Beispiel #3
0
        public void CacheAttributeTestCase()
        {
            CacheTestClass foo = new CacheTestClass();

            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine(foo.GetDateTime());
                Console.WriteLine(foo.GetDateTime2());
                Console.WriteLine(foo.GetDateTime3());
                DataSet ds = foo.GetDataSet();
                Console.WriteLine(ds.DataSetName);
                foreach (DataTable dt in ds.Tables)
                {
                    Console.WriteLine(dt.TableName);
                    foreach (DataRow dr in dt.Rows)
                    {
                        foreach (DataColumn dc in dt.Columns)
                        {
                            Console.Write("{0}: {1}\t", dc.ColumnName, dr[dc]);
                        }
                        Console.WriteLine();
                    }
                }

                ds = foo.GetDataSet("whatever");
                Console.WriteLine(ds.DataSetName);
                foreach (DataTable dt in ds.Tables)
                {
                    Console.WriteLine(dt.TableName);
                    foreach (DataRow dr in dt.Rows)
                    {
                        foreach (DataColumn dc in dt.Columns)
                        {
                            Console.Write("{0}: {1}\t", dc.ColumnName, dr[dc]);
                        }
                        Console.WriteLine();
                    }
                }

                Thread.Sleep(1000);
            }
        }
        public void CacheAttributeTestCase()
        {
            CacheTestClass foo = new CacheTestClass();
            for (int i = 0; i < 7; i++)
            {
                Console.WriteLine(foo.GetDateTime());
                Console.WriteLine(foo.GetDateTime2());
                Console.WriteLine(foo.GetDateTime3());
                DataSet ds = foo.GetDataSet();
                Console.WriteLine(ds.DataSetName);
                foreach (DataTable dt in ds.Tables)
                {
                    Console.WriteLine(dt.TableName);
                    foreach (DataRow dr in dt.Rows)
                    {
                        foreach (DataColumn dc in dt.Columns)
                            Console.Write("{0}: {1}\t", dc.ColumnName, dr[dc]);
                        Console.WriteLine();
                    }
                }

                ds = foo.GetDataSet("whatever");
                Console.WriteLine(ds.DataSetName);
                foreach (DataTable dt in ds.Tables)
                {
                    Console.WriteLine(dt.TableName);
                    foreach (DataRow dr in dt.Rows)
                    {
                        foreach (DataColumn dc in dt.Columns)
                            Console.Write("{0}: {1}\t", dc.ColumnName, dr[dc]);
                        Console.WriteLine();
                    }
                }

                Thread.Sleep(1000);
            }
        }