Esempio n. 1
0
        public void WithoutCultureArg12()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! \u00a41.00\u00a42.00\u00a43.00\u00a44.00\u00a45.00\u00a46.00\u00a47.00\u00a48.123.142014-01-2212:33:53-9,000"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                "Hello, World! {0:C}{1:C}{2:C}{3:C}{4:C}{5:C}{6:C}{7:C}{8:#0.00}{9:yyyy-MM-dd}{10}{11:#,##0}",
                1, 2, 3, 4, 5, 6, 7, 8.12m, Math.PI, new DateTime(2014, 1, 22), new TimeSpan(12, 33, 53), -9000);
            Assert.That(invoked, Is.True);
        }
Esempio n. 2
0
        public void WithoutCultureArg9()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! \u00a41.00\u00a42.00\u00a43.00\u00a44.00\u00a45.00\u00a46.00\u00a47.00\u00a48.123.14"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                "Hello, World! {0:C}{1:C}{2:C}{3:C}{4:C}{5:C}{6:C}{7:C}{8:#0.00}",
                1, 2, 3, 4, 5, 6, 7, 8.12m, Math.PI);
            Assert.That(invoked, Is.True);
        }
Esempio n. 3
0
        public void WithoutCultureArg1()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! \u00a41.00"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                "Hello, World! {0:C}",
                1);
            Assert.That(invoked, Is.True);
        }
Esempio n. 4
0
        public void WithCultureArgs()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! $1.00$2.00$3.00$4.00$5.00$6.00$7.00$8.123.142014-01-2212:33:53-9,000abcd123&"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                CultureInfo.GetCultureInfo("en-US"),
                "Hello, World! {0:C}{1:C}{2:C}{3:C}{4:C}{5:C}{6:C}{7:C}{8:#0.00}{9:yyyy-MM-dd}{10}{11:#,##0}{12}{13}{14}{15}{16}",
                new object[] { 1, 2, 3, 4, 5, 6, 7, 8.12m, Math.PI, new DateTime(2014, 1, 22), new TimeSpan(12, 33, 53), -9000, 'a', 'b', "cd", "123", '&' });
            Assert.That(invoked, Is.True);
        }
Esempio n. 5
0
        public void WithCultureArg10()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! $1.00$2.00$3.00$4.00$5.00$6.00$7.00$8.123.142014-01-22"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                CultureInfo.GetCultureInfo("en-US"),
                "Hello, World! {0:C}{1:C}{2:C}{3:C}{4:C}{5:C}{6:C}{7:C}{8:#0.00}{9:yyyy-MM-dd}",
                1, 2, 3, 4, 5, 6, 7, 8.12m, Math.PI, new DateTime(2014, 1, 22));
            Assert.That(invoked, Is.True);
        }
Esempio n. 6
0
        public void WithCultureArg5()
        {
            Mock <ILog> mock           = new Mock <ILog>();
            string      callerName     = this.ObtainCallerName();
            string      callerFilePath = Path.GetFileName(this.ObtainCallerFilePath());
            bool        invoked        = false;

            mock
            .Setup(x => x.Info(It.IsAny <object>()))
            .Callback <object>(x =>
            {
                Assert.That(x, Is
                            .Not.Null
                            .And.StringContaining(callerName)
                            .And.StringContaining(callerFilePath)
                            .And.StringMatching(":[0-9]+")
                            .And.StringEnding("Hello, World! $1.00$2.00$3.00$4.00$5.00"));
                invoked = true;
            });

            CallerInfoLog log = new CallerInfoLog(mock.Object);

            log.InfoFormat(
                CultureInfo.GetCultureInfo("en-US"),
                "Hello, World! {0:C}{1:C}{2:C}{3:C}{4:C}",
                1, 2, 3, 4, 5);
            Assert.That(invoked, Is.True);
        }