Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please inform your name: ");
            var name            = Console.ReadLine();
            var greetingService = new DefaultGreetingService(new SystemClock());

            Console.WriteLine(greetingService.Greet(name));
            Console.ReadLine();
        }
        public void Greeting(
            int hour,
            int minute,
            int second,
            string userName,
            string expectedGreeting)
        {
            IClock clock = new StoppedClock(new DateTimeOffset(
                                                new DateTime(2018, 1, 1, hour, minute, second),
                                                TimeSpan.FromHours(-2)));

            var sut = new DefaultGreetingService(clock);

            Assert.AreEqual(expectedGreeting, sut.Greet(userName));
        }
        public void Greeting_WithInvalidName_Throws()
        {
            IClock clock = new StoppedClock(new DateTimeOffset(
                                                new DateTime(2018, 1, 1, 14, 15, 0),
                                                TimeSpan.FromHours(-2)));

            var sut = new DefaultGreetingService(clock);

            Assert.Multiple(() =>
            {
                Assert.Throws <ArgumentException>(() => sut.Greet(null));
                Assert.Throws <ArgumentException>(() => sut.Greet(string.Empty));
                Assert.Throws <ArgumentException>(() => sut.Greet("  "));
                Assert.Throws <ArgumentException>(() => sut.Greet("\n\n\t"));
            });
        }