Пример #1
0
        public void SaveContactEmail_Success()
        {
            // Arrange
            contactEmailViewModel = new ContactEmailViewModel
            {
                ContactID         = 1,
                ContactEmailID    = 0,
                Email             = "*****@*****.**",
                EmailID           = 1,
                EmailPermissionID = 1,
                IsPrimary         = true,
                ForceRollback     = true
            };

            var controller = new ContactEmailController(new ContactEmailRepository(token));

            // Act

            var result       = controller.AddUpdateEmail(contactEmailViewModel);
            var jsonResponse = result as JsonResult;
            var data         = result.Data;
            var response     = data as Response <ContactEmailViewModel>;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.DataItems, "Data items can't be null");
            Assert.IsTrue(response.ResultCode == 0, "Insert success");
            Assert.IsTrue(response.RowAffected > 0, "Contact Email could not be created.");
        }
Пример #2
0
        public void UpdateContactEmail_Failed()
        {
            // Arrange
            var controller = new ContactEmailController(new ContactEmailRepository(token));

            // Act
            var contactEmailViewModel = new ContactEmailViewModel
            {
                ContactID         = 0,
                ContactEmailID    = -1,
                Email             = "*****@*****.**",
                EmailID           = 0,
                EmailPermissionID = 0,
                IsPrimary         = true,
                ForceRollback     = true
            };
            var result       = controller.AddUpdateEmail(contactEmailViewModel);
            var jsonResponse = result as JsonResult;
            var data         = result.Data;
            var response     = data as Response <ContactEmailViewModel>;


            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsTrue(response.ResultCode > 0, "Failed to update");
            Assert.IsTrue(response.RowAffected > 0, "Email updated for invalid data.");
        }
 public void Initialize()
 {
     //Arrange
     demographicsController = new RegistrationController(new RegistrationRepository(ConfigurationManager.AppSettings["UnitTestToken"]));
     headerController       = new ReferralHeaderController(new ReferralHeaderRepository(ConfigurationManager.AppSettings["UnitTestToken"]));
     addressController      = new ContactAddressController(new ContactAddressRepository(ConfigurationManager.AppSettings["UnitTestToken"]));
     emailController        = new ContactEmailController(new ContactEmailRepository(ConfigurationManager.AppSettings["UnitTestToken"]));
     phoneController        = new ContactPhoneController(new ContactPhoneRepository(ConfigurationManager.AppSettings["UnitTestToken"]));
 }
Пример #4
0
        public void DeleteContactEmail_Success()
        {
            // Arrange
            var controller = new ContactEmailController(new ContactEmailRepository(token));

            var result       = controller.DeleteEmail(1);
            var jsonResponse = result as JsonResult;
            var data         = result.Data;
            var response     = data as Response <ContactEmailViewModel>;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsTrue(response.RowAffected == 4, "Email deleted successfully"); //Audit in delete SP always affects 3 rows, so check is applied if 4th row is affected.
        }
Пример #5
0
        public void DeleteContactEmail_Failed()
        {
            Mock_ContactEmails_Failed();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailRuleEngine);

            //Act
            var savecontactEmailsResult = contactEmailsController.DeleteEmail(-1, DateTime.UtcNow);
            var response = savecontactEmailsResult as HttpResult <Response <ContactEmailModel> >;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Response value cann't be null");
            Assert.AreEqual(0, response.Value.RowAffected, "Row affected should greater than 0");
        }
Пример #6
0
        public void DeleteContactEmail_Success()
        {
            Mock_ContactEmails_Success();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailRuleEngine);

            //Act
            var savecontactEmailsResult = contactEmailsController.DeleteEmail(contactId, DateTime.UtcNow);
            var response     = savecontactEmailsResult as HttpResult <Response <ContactEmailModel> >;
            var contactEmail = response.Value.DataItems;

            // Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Response value cann't be null");
            Assert.IsNotNull(response.Value.RowAffected, "contact email could not be deleted.");
        }
Пример #7
0
        public void GetcontactEmail_Failed()
        {
            Mock_ContactEmails_Failed();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailRuleEngine);

            //Act
            var getcontactEmailsResult = contactEmailsController.GetEmails(-1, 0);
            var response = getcontactEmailsResult as HttpResult <Response <ContactEmailModel> >;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Record does not exist");
            Assert.IsNotNull(response.Value.DataItems, "Record does not exist");
            Assert.IsTrue(response.Value.DataItems.Count == 0, "Record does not exist");
        }
Пример #8
0
        public void GetcontactEmail_Success()
        {
            Mock_ContactEmails_Success();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailRuleEngine);

            //Act
            var getcontactEmailsResult = contactEmailsController.GetEmails(contactId, 1);
            var response = getcontactEmailsResult as HttpResult <Response <ContactEmailModel> >;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Response value cann't be null");
            Assert.IsNotNull(response.Value.DataItems, "Data items can't be null");
            Assert.IsTrue(response.Value.DataItems.Count() > 0, "Atleast one Contact Email must exists.");
        }
Пример #9
0
        public void GetContactEmail_Failed()
        {
            // Arrange
            var controller = new ContactEmailController(new ContactEmailRepository(token));

            // Act
            var result       = controller.GetEmails(0);
            var jsonResponse = result as JsonResult;
            var data         = result.Data;
            var response     = data as Response <ContactEmailViewModel>;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.DataItems, "Data items can't be null");
            Assert.IsTrue(response.DataItems.Count == 0, "Record exist for invalid data");
        }
Пример #10
0
        public void GetContactEmail_Success()
        {
            // Arrange
            var controller = new ContactEmailController(new ContactEmailRepository(token));

            // Act
            var result       = controller.GetEmails(contactId);
            var jsonResponse = result as JsonResult;
            var data         = result.Data;
            var response     = data as Response <ContactEmailViewModel>;


            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.DataItems, "Data items can't be null");
            Assert.IsTrue(response.DataItems.Count > 0, "Atleast one contact email must exists.");
        }
Пример #11
0
        public void UpdateContactEmail_Failed()
        {
            Mock_ContactEmails_Failed();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailRuleEngine);

            //Act
            List <ContactEmailModel> contactEmails = new List <ContactEmailModel>();

            contactEmails.Add(contactEmailsModel);
            var savecontactEmailsResult = contactEmailsController.AddUpdateEmail(contactEmails);
            var response = savecontactEmailsResult as HttpResult <Response <ContactEmailModel> >;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Response value cann't be null");
            Assert.IsNotNull(response.Value.DataItems, "Data item cann't be null");
        }
        public void AddContactEmail_Failed()
        {
            Mock_ContactEmails_Failed();
            // Arrange
            ContactEmailController contactEmailsController = new ContactEmailController(contactEmailDataProvider);

            //Act
            List <ContactEmailModel> contactEmails = new List <ContactEmailModel>();

            contactEmails.Add(contactEmailsModel);
            var savecontactEmailsResult = contactEmailsController.AddUpdateEmails(contactEmails);
            var response = savecontactEmailsResult as HttpResult <Response <ContactEmailModel> >;

            //Assert
            Assert.IsNotNull(response, "Response cann't be null");
            Assert.IsNotNull(response.Value, "Response value cann't be null");
            Assert.IsNotNull(response.Value.DataItems, "Email inserted for wrong data");
        }