Beispiel #1
0
        public void NoCustomerBetter()
        {
            var customerRepo = new InMemoryCustomerRepo();
            var display      = new DisplaySpy();
            var superMega    = new SuperMegaUseCase(customerRepo, display);

            superMega.DoSomething();

            Assert.Equal("", display.Output);
        }
Beispiel #2
0
        public void ManyCustomersBetter()
        {
            var customerRepo = new InMemoryCustomerRepo("massimo", "matteo");
            var display      = new DisplaySpy();
            var superMega    = new SuperMegaUseCase(customerRepo, display);

            superMega.DoSomething();

            Assert.Contains("massimo", display.Output);
            Assert.Contains("matteo", display.Output);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            //File.WriteAllLines("customers.txt", new []{"massimo", "matteo"});
            File.WriteAllLines("customers.txt", new string[0]);

            var superMega = new SuperMegaUseCase(new FlatFileCustomerRepo("customers.txt"), new ConsoleDisplay());

            superMega.DoSomething();

            Console.WriteLine("\n\n\nPress any key to exit");
            Console.ReadKey();
        }
Beispiel #4
0
        public void NoCustomer()
        {
            var customerRepo = new Mock <ICustomerRepo>();
            var display      = new Mock <IDisplay>();

            customerRepo.Setup(x => x.LoadAll()).Returns(new string[0]);
            var superMega = new SuperMegaUseCase(customerRepo.Object, display.Object);

            superMega.DoSomething();

            display.Verify(d => d.Show(It.IsAny <string>()), Times.Never);
        }
Beispiel #5
0
        public void ManyCustomers()
        {
            var customerRepo = new Mock <ICustomerRepo>();
            var display      = new Mock <IDisplay>();

            customerRepo.Setup(x => x.LoadAll()).Returns(new[] { "massimo", "matteo" });
            var superMega = new SuperMegaUseCase(customerRepo.Object, display.Object);

            superMega.DoSomething();

            display.Verify(d => d.Show("massimo"), Times.Once);
            display.Verify(d => d.Show("matteo"), Times.Once);
        }