public void RunCustomerReportsShouldSendEmails()
        {
            // arrange
            var expectedCustomer = new Customer("*****@*****.**");
            const string expectedReportBody = "This is the expected report body";

            _customerDataMock.Setup(c => c.GetCustomersForReport()).Returns(new[] { expectedCustomer });

            _reportBuilderMock.Setup(r => r.CreateCustomerReport(expectedCustomer))
                .Returns(new Report(expectedCustomer.Email, expectedReportBody));

            var sut = new ReportingService(_customerDataMock.Object, _reportBuilderMock.Object, _emailerMock.Object);

            // act
            sut.RunCustomerReports();

            // assert
            _emailerMock.Verify(e => e.Send(expectedCustomer.Email, expectedReportBody));
        }
Exemplo n.º 2
0
 public Report CreateCustomerReport(Customer customer)
 {
     return new Report(customer.Email, $"This is a report for {customer.Email}");
 }