public void Test_InsertAddressAndReturnOk()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas data    = new Datas();

            _userRepository.Setup(r => r.AddAddress(data.SetAddressForTest));
            _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult result = _controller.AddAddress(data.SetAddressForTest);

            Assert.IsType <OkObjectResult>(result);
        }
        public void Test_InsertAddressAndReturn()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas datas   = new Datas();

            _userRepository.Setup(r => r.AddAddress(datas.SetAddressForTest));
            AddressController _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult  result         = _controller.AddAddress(datas.SetAddressForTest);
            OkObjectResult okObjectResult = result as OkObjectResult;
            Address        returnResult   = okObjectResult.Value as Address;

            Assert.Equal(datas.SetAddressForTest.Id, returnResult.Id);
            Assert.Equal(datas.SetAddressForTest.UserName, returnResult.UserName);
            Assert.Equal(datas.SetAddressForTest.AddressLine, returnResult.AddressLine);
            Assert.Equal(datas.SetAddressForTest.AddressType, returnResult.AddressType);
            Assert.Equal(datas.SetAddressForTest.City, returnResult.City);
            Assert.Equal(datas.SetAddressForTest.State, returnResult.State);
            Assert.Equal(datas.SetAddressForTest.ZipCode, returnResult.ZipCode);
            Assert.Equal(datas.SetAddressForTest.Country, returnResult.Country);
        }
Exemple #3
0
        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    PortalSecurity security = new PortalSecurity();

                    AddressInfo address = new AddressInfo();

                    address.AddressID = _addressID;
                    address.PortalID = this.PortalId;
                    address.UserID = this.UserId;
                    address.Description = security.InputFilter(txtDescription.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Name = security.InputFilter(txtName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Address1 = security.InputFilter(txtAddress1.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Address2 = security.InputFilter(txtAddress2.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.City = security.InputFilter(txtCity.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.CountryCode = cboCountry.SelectedValue;
                    address.RegionCode = cboRegion.SelectedValue;
                    address.PostalCode = security.InputFilter(txtPostalCode.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Phone1 = security.InputFilter(txtPhone1.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.Phone2 = security.InputFilter(txtPhone2.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoSQL);
                    address.PrimaryAddress = chkPrimary.Checked;
                    address.CreatedByUser = this.UserId.ToString();
                    address.CreatedDate	= DateTime.Now;

                    AddressController controller = new AddressController();

                    if (Null.IsNull(address.AddressID) || address.AddressID == 0)
                    {
                        controller.AddAddress(address);
                    }
                    else
                    {
                        controller.UpdateAddress(address);
                    }

                    invokeEditComplete();
                }
            }
            catch(Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }