Ejemplo n.º 1
0
        public void Try_Fallback_true()
        {
            int IsFallback = 0;

            Action         action         = () => throw new ContextMarshalException();
            Action         fallback       = () => IsFallback = 1;
            FaultTolerance faultTolerance = new FaultTolerance();

            faultTolerance.Fallback(action, fallback);

            Assert.AreEqual(1, IsFallback);
        }
Ejemplo n.º 2
0
        public void Try_StringEquals_false()
        {
            StringBuilder actual   = new StringBuilder();
            StringBuilder expected = new StringBuilder("Hello Somebody");
            Action        action   = () => throw new ArgumentException();
            Action        fallBack = () =>
            {
                actual.Append("Hello Somebody");
            };
            FaultTolerance faultTolerance = new FaultTolerance();

            faultTolerance.Fallback(action, fallBack);

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Ejemplo n.º 3
0
        public void Try_SquareFallback_false()
        {
            Random rand     = new Random();
            int    actual   = rand.Next(100);
            int    expected = actual * actual;

            int    IsFallback = 0;
            Action fallBack   = () => IsFallback = 1;

            Action action = () =>
            {
                actual *= actual;
            };
            FaultTolerance faultTolerance = new FaultTolerance();

            faultTolerance.Fallback(action, fallBack);
            Assert.AreEqual(0, IsFallback);
        }