Esempio n. 1
0
 public void Callback_TooManyArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.OneArgument(1))
             .Callback <int, int>((a, b) => { });
         });
     });
 }
Esempio n. 2
0
 public void Callback_TooManyVoidMethodArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => Console.WriteLine("{0}"))
             .Callback <string, int>((a, b) => { });
         });
     });
 }
 public void Callback_VoidLessThanExpectedTwoArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.VoidTwoArguments(1, 2))
             .Callback <int>((a) => { });
         });
     });
 }
Esempio n. 4
0
 public void Callback_TooFewArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.TwoArguments(1, 2))
             .Callback <int>(a => { });
         });
     });
 }
Esempio n. 5
0
        public void test()
        {
            Smock.Run(context =>
            {
                context.Setup(() => DateTime.Now).Returns(new DateTime(2000, 1, 1));

                var dateNow = DateTime.Now;
                Assert.That(dateNow, Is.EqualTo(new DateTime(3000, 1, 1)));
                Console.WriteLine("ttu");
                Thread.Sleep(2220);
            });
        }
 public void Callback_LessThanExpectedSixteenArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.SixteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))
             .Callback <int, int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) => { });
         });
     });
 }
 public void Callback_LessThanExpectedTwelveArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.TwelveArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
             .Callback <int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k) => { });
         });
     });
 }
Esempio n. 8
0
        public void Setup_MultipleItIsSetups_MatchesTheCorrectSetup()
        {
            Smock.Run(context =>
            {
                context.Setup(() => string.Format(It.Is <string>(format => format.Contains("A")))).Returns("Foo");
                context.Setup(() => string.Format(It.Is <string>(format => format.Contains("B")))).Returns("Bar");

                Assert.AreEqual("Foo", string.Format("AA"));
                Assert.AreEqual("Bar", string.Format("BB"));
                Assert.AreEqual("CC", string.Format("CC"));
            });
        }
 public void Callback_LessThanExpectedEightArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.EightArguments(1, 2, 3, 4, 5, 6, 7, 8))
             .Callback <int, int, int, int, int, int, int>((a, b, c, d, e, f, g) => { });
         });
     });
 }
 public void Callback_MoreThanExpectedNineArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.NineArguments(1, 2, 3, 4, 5, 6, 7, 8, 9))
             .Callback <int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, z) => { });
         });
     });
 }
 public void Callback_VoidLessThanExpectedOneArgument_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.VoidOneArgument(1))
             .Callback(() => { });
         });
     });
 }
 public void Callback_VoidMoreThanExpectedSixArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.VoidSixArguments(1, 2, 3, 4, 5, 6))
             .Callback <int, int, int, int, int, int, int>((a, b, c, d, e, f, z) => { });
         });
     });
 }
 public void Callback_LessThanExpectedFourArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.FourArguments(1, 2, 3, 4))
             .Callback <int, int, int>((a, b, c) => { });
         });
     });
 }
Esempio n. 14
0
        public void Verify_VerifiablePropertySetupNotMatched_ThrowsException()
        {
            Assert.Throws <VerificationException>(() =>
            {
                Smock.Run(context =>
                {
                    context.Setup(() => DateTime.Now).Verifiable();

                    context.Verify();
                });
            });
        }
 public void Callback_VoidMoreThanExpectedThirteenArguments_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.VoidThirteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))
             .Callback <int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, z) => { });
         });
     });
 }
Esempio n. 16
0
        public void NewCombTest()
        {
            DateTime now = DateTime.Now;

            Smock.Run(context =>
            {
                context.Setup(() => DateTime.Now).Returns(now);
                Guid id       = CombHelper.NewComb();
                DateTime time = CombHelper.GetDateFromComb(id);
                Assert.True(time.Subtract(now).TotalSeconds < 1);
            });
        }
 public void Callback_MoreThanExpectedOneArgument_ThrowsException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Smock.Run(context =>
         {
             context
             .Setup(() => TestFunctions.OneArgument(1))
             .Callback <int, int>((a, z) => { });
         });
     });
 }
Esempio n. 18
0
        public void Raise_StaticEvent_RaisesInvokedEvent()
        {
            bool invoked = false;

            Smock.Run(context =>
            {
                Console.CancelKeyPress += (sender, args) => invoked = true;
                context.Raise(() => Console.CancelKeyPress += null, () => Console.CancelKeyPress -= null, default(EventArgs));
            });

            Assert.IsTrue(invoked);
        }
Esempio n. 19
0
        public void Callback_SingleConvertibleArg_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int result = 0;
                context.Setup(() => Math.Sqrt(It.IsAny <double>())).Callback <int>(d => result = d * d);

                Math.Sqrt(2.0);

                Assert.AreEqual(4, result);
            });
        }
Esempio n. 20
0
        public void Verify_VerifiableMethodSetupNotMatched_ThrowsException()
        {
            Assert.Throws <VerificationException>(() =>
            {
                Smock.Run(context =>
                {
                    context.Setup(() => Console.WriteLine()).Verifiable();

                    context.Verify();
                });
            });
        }
Esempio n. 21
0
        public void Callback_VoidThreeMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidThreeArguments(1, 2, 3))
                .Callback <int, int, int>((a, b, c) => sum = a + b + c);

                TestFunctions.VoidThreeArguments(1, 2, 3);
                Assert.AreEqual(6, sum);
            });
        }
Esempio n. 22
0
        public void Callback_TwoMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.TwoArguments(1, 2))
                .Callback <int, int>((a, b) => sum = a + b);

                TestFunctions.TwoArguments(1, 2);
                Assert.AreEqual(3, sum);
            });
        }
Esempio n. 23
0
        public void Callback_VoidSixteenMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidSixteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))
                .Callback <int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) => sum = a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p);

                TestFunctions.VoidSixteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
                Assert.AreEqual(136, sum);
            });
        }
Esempio n. 24
0
        public void Callback_VoidTwelveMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidTwelveArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
                .Callback <int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l) => sum = a + b + c + d + e + f + g + h + i + j + k + l);

                TestFunctions.VoidTwelveArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
                Assert.AreEqual(78, sum);
            });
        }
Esempio n. 25
0
        public void Callback_ThirteenMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.ThirteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13))
                .Callback <int, int, int, int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j, k, l, m) => sum = a + b + c + d + e + f + g + h + i + j + k + l + m);

                TestFunctions.ThirteenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
                Assert.AreEqual(91, sum);
            });
        }
Esempio n. 26
0
        public void Callback_TenMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.TenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
                .Callback <int, int, int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h, i, j) => sum = a + b + c + d + e + f + g + h + i + j);

                TestFunctions.TenArguments(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
                Assert.AreEqual(55, sum);
            });
        }
Esempio n. 27
0
        public void Callback_VoidOneMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidOneArgument(1))
                .Callback <int>((a) => sum = a);

                TestFunctions.VoidOneArgument(1);
                Assert.AreEqual(1, sum);
            });
        }
Esempio n. 28
0
        public void Callback_VoidEightMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidEightArguments(1, 2, 3, 4, 5, 6, 7, 8))
                .Callback <int, int, int, int, int, int, int, int>((a, b, c, d, e, f, g, h) => sum = a + b + c + d + e + f + g + h);

                TestFunctions.VoidEightArguments(1, 2, 3, 4, 5, 6, 7, 8);
                Assert.AreEqual(36, sum);
            });
        }
Esempio n. 29
0
        public void Callback_SevenMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.SevenArguments(1, 2, 3, 4, 5, 6, 7))
                .Callback <int, int, int, int, int, int, int>((a, b, c, d, e, f, g) => sum = a + b + c + d + e + f + g);

                TestFunctions.SevenArguments(1, 2, 3, 4, 5, 6, 7);
                Assert.AreEqual(28, sum);
            });
        }
Esempio n. 30
0
        public void Callback_VoidSixMatchingArgs_InvokesCallbackWithArguments()
        {
            Smock.Run(context =>
            {
                int sum = 0;
                context
                .Setup(() => TestFunctions.VoidSixArguments(1, 2, 3, 4, 5, 6))
                .Callback <int, int, int, int, int, int>((a, b, c, d, e, f) => sum = a + b + c + d + e + f);

                TestFunctions.VoidSixArguments(1, 2, 3, 4, 5, 6);
                Assert.AreEqual(21, sum);
            });
        }