Пример #1
0
        private void btnCount_Click(object sender, RoutedEventArgs e)
        {
            int    count = businessService.GetCountOfNames(txtSearchCount.Text);
            string msg   = $"The number of {txtSearchCount.Text} is {count}";

            MessageBox.Show(msg);
        }
        public void TestMethod1()
        {
            // need to moq the function that connect to db and fetches the data
            List <Customer> fakeCustomers = new List <Customer>();

            fakeCustomers.Add(new Customer {
                Name = "A"
            });
            fakeCustomers.Add(new Customer {
                Name = "A"
            });
            fakeCustomers.Add(new Customer {
                Name = "B"
            });

            var mock = new Mock <ICustomerService>();

            mock.Setup(x => x.GetCustomers()).Returns(fakeCustomers);

            CustomerBusinessService serviceTobeTested = new CustomerBusinessService(mock.Object);

            Assert.IsTrue(serviceTobeTested.GetCountOfNames("A") == 2);
        }