Ejemplo n.º 1
0
        public async Task TravelNotificationServiceTests_EmailNotifyStatusChange_Completed_Test()
        {
            var emailer = new Common.Notification.Fakes.StubIEmailer()
            {
                InstanceObserver = new StubObserver()
            };
            var templatesRepository = new Common.Notification.Fakes.StubIEmailTemplatesRepository();
            var employeesRepository = new Data.Repositories.Fakes.StubIEmployeeRepository();

            employeesRepository.GetAsyncInt32 = (id) =>
            {
                return(Task.FromResult(new Employee()
                {
                    EmployeeId = id,
                    FirstName = "My",
                    LastName = "Employee",
                    Email = "*****@*****.**"
                }));
            };

            TravelNotificationService service       = new TravelNotificationService(emailer, templatesRepository, employeesRepository);
            TravelRequest             travelRequest = new TravelRequest()
            {
                Status = TravelRequestStatus.Completed
            };

            await service.EmailNotifyStatusChange(travelRequest, "my reason");

            var observer = (StubObserver)emailer.InstanceObserver;

            Assert.AreEqual(1, observer.GetCalls().Count(c => c.StubbedMethod.Name == "Send"));
        }
Ejemplo n.º 2
0
        public void TravelNotificationService_Constructor_NullEmployeeRepository_Test()
        {
            IEmailer emailer = new Common.Notification.Fakes.StubIEmailer()
            {
                InstanceObserver = new StubObserver()
            };
            IEmailTemplatesRepository templatesRepository = new Common.Notification.Fakes.StubIEmailTemplatesRepository();
            IEmployeeRepository       employeesRepository = null;

            TravelNotificationService service = new TravelNotificationService(emailer, templatesRepository, employeesRepository);
        }