public void When_handle_Then_should_call_correct_methods()
        {
            // Given
            var handler = CreateTarget();
            var message = new SendSafeCheckChecklistCompletedEmail()
            {
                ChecklistId = _checklist.Id,
                Can = "Demo001",
                Postcode = "M1 1AA"
            };

            // When
            handler.Handle(message);

            // Then
            _emailSender.Verify(x => x.Send(It.IsAny<RazorEmailResult>()));
        }
        public HttpResponseMessage SendChecklistCompleteEmailNotification(Guid id)
        {
            try
            {
                var checklist = _checklistRepository.GetById(id);

                if (checklist == null)
                {
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound,
                        "Checklist: " + id + "Not Found."));
                }

                var sendChecklistCompleteEmail = new SendSafeCheckChecklistCompletedEmail()
                {
                     ChecklistId = checklist.Id
                };

                if (checklist.ClientId.HasValue)
                {
                    var clientDetail = _clientDetailsService.Get(checklist.ClientId.Value);

                    var site = checklist.SiteId.HasValue
                        ? _clientDetailsService.GetSite(checklist.ClientId.Value, checklist.SiteId.Value)
                        : null;

                    var postcode = site != null ? site.Postcode : "";

                    sendChecklistCompleteEmail.Can = clientDetail.CAN;
                    sendChecklistCompleteEmail.Postcode = postcode;
                }
                else
                {
                    sendChecklistCompleteEmail.Can = "Not specified";
                    sendChecklistCompleteEmail.Postcode = "Not specified";
                }

                _bus.Send(sendChecklistCompleteEmail);
            }

            catch (Exception ex)
            {
                LogManager.GetLogger(typeof(ChecklistController)).Error(ex);
                throw;
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }