Beispiel #1
0
        public async Task Index()
        {
            // Arrange
            EMailController      controller           = new EMailController();
            EmailIndexInputModel emailIndexInputModel = new EmailIndexInputModel();

            emailIndexInputModel.id       = 1;
            emailIndexInputModel.UserName = "******";
            // Act
            ActionResult result = await controller.Index(emailIndexInputModel);

            // Assert
            Assert.IsTrue(((ViewResultBase)result).Model.Equals("Successful"));
        }
        // GET: EMail
        public async Task <ActionResult> Index(EmailIndexInputModel emailIndexInputModel)
        {
            object obj = new object();

            if (ModelState.IsValid)
            {
                try
                {
                    EmailManager emailManager = new EmailManager();
                    await emailManager.SendEmailByIdAndUserName(emailIndexInputModel.id, emailIndexInputModel.UserName);

                    obj = "Successful";
                }
                catch (Exception e)
                {
                    //TODO: Set model message as "Please try later";
                    obj = "Failed";
                }
            }
            return(View(obj));
        }