Esempio 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"));
        }
        public void VacationNotificationServiceTests_WithDeniedStatus_EmailNotifyStatusChange_Denied_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.GetInt32 = (id) =>
            {
                return(new Employee()
                {
                    EmployeeId = id,
                    FirstName = "My",
                    LastName = "Employee",
                    Email = "*****@*****.**"
                });
            };

            VacationNotificationService service         = new VacationNotificationService(emailer, templatesRepository, employeesRepository);
            VacationRequest             vacationRequest = new VacationRequest()
            {
                Status = VacationRequestStatus.Denied
            };

            service.NotifyStatusChange(vacationRequest, string.Empty);

            var observer = (StubObserver)emailer.InstanceObserver;

            Assert.AreEqual(1, observer.GetCalls().Count(c => c.StubbedMethod.Name == "Send"));
        }
Esempio n. 3
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);
        }
        public void VacationNotificationServiceTests_NotifyNewVacationRequest_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.GetInt32 = (id) =>
            {
                return(new Employee()
                {
                    EmployeeId = id,
                    FirstName = "My",
                    LastName = "Employee",
                    Email = "*****@*****.**",
                    Team = new Team()
                    {
                        Manager = new Employee()
                        {
                            FirstName = "Manager",
                            LastName = "LastName",
                            Email = "*****@*****.**"
                        }
                    }
                });
            };

            VacationNotificationService service         = new VacationNotificationService(emailer, templatesRepository, employeesRepository);
            VacationRequest             vacationRequest = new VacationRequest()
            {
                EmployeeId = 1
            };

            service.NotifyNewVacationRequest(vacationRequest);

            var observer = (StubObserver)emailer.InstanceObserver;

            Assert.AreEqual(1, observer.GetCalls().Count(c => c.StubbedMethod.Name == "Send"));
        }