public void RegisterController_RegisterActionCalledAndModelStateIsValid_RegisterWillBeCalled()
        {
            _register.RegisterCompany(Arg.Any <RegisterModel>()).Returns("");
            var registerCallCount = 0;

            _emailSender.When(x => x.SendMail(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>())).DoNotCallBase();
            _register.When(x => x.RegisterCompany(Arg.Any <RegisterModel>())).Do(x =>
            {
                registerCallCount++;
            });
            RegisterController controllerUnderTest = new RegisterController(_register, _emailSender);

            controllerUnderTest.ModelState.Clear();
            var registerModel = GetRegisterModel();

            controllerUnderTest.Register(registerModel);

            Assert.AreEqual(registerCallCount, 1);
        }
        public JsonResult Register(RegisterModel model)
        {
            string result;

            if (ModelState.IsValid)
            {
                result = _register.RegisterCompany(model);
                if (string.IsNullOrWhiteSpace(result))  // if no error message send email if it is enabled in config
                {
                    _emailSender.SendMail(model.ContactInfo.Contact.EmailId, "New Client Registered!", "You have been added successfully in travel.com.");
                }
            }
            else
            {
                result = Constants.InvalidDataError;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }