[TestMethod()]//Check if the help links are being inserted in the database from xml.
        public void InsertHelpLinkTestToCheckInsertionOfHelpLinksInDatabase()
        {
            //Act
            var accinfo = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);

            foreach (Link hl in input.HelpLink.Links)
            {
                var actualresult = AvaTaxProfileAssistantHelper.InsertHelpLink(hl, accinfo.ID);

                //Assert
                Assert.AreEqual(true, actualresult, "HelpLink insertion in database failed!!");
            }
        }
        [TestMethod()]//Check if the method returns a list of HelpLinks.
        public void GetLinkListTestToCheckIfItReturnsListOfHelpLinks()
        {
            //Arrange
            var accinfo = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);

            //Act
            var             actualresult   = AvaTaxProfileAssistantHelper.GetLinkList(accinfo.ID);
            List <HelpLink> expectedresult = new List <HelpLink>();

            //Assert
            Assert.AreEqual(expectedresult.GetType(), actualresult.GetType(), "The method failed to return a list of helplinks!!");
            Assert.IsNotNull(actualresult, "The list does not contain any records!!");
        }
        [TestMethod()]//Check if the method returns correct state and company code
        public void ParseStateCountryTestToCheckIfItReturnsCorrectStateAndComapnyCode()
        {
            //Arrange
            string country     = "USA";
            string state       = "WASHINGTON";
            string StateCode   = "";
            string CountryCode = "";


            //Act
            AvaTaxProfileAssistantHelper.ParseStateCountry(state, country, out StateCode, out CountryCode);
            Assert.AreEqual("US", CountryCode, "Incorrect CountryCode returned!!");
            Assert.AreEqual("WA", StateCode, "Incorrect state code!!");
        }
        [TestMethod()]//Check if it trims the state code to first 2 letters.
        public void TrimCodeTestToCheckIfFirstTwoLettersOfStringAreReturned()
        {
            //Arrange
            string state   = "WASHINGTON";
            string country = "USA";

            //Act
            var StateResult   = AvaTaxProfileAssistantHelper.TrimCode(state);
            var CountryResult = AvaTaxProfileAssistantHelper.TrimCode(country);

            //Assert
            Assert.AreEqual("WA", StateResult, "Incorrect state code returned!!");
            Assert.AreEqual("US", CountryResult, "Incorrect country code returned!!");
        }
Beispiel #5
0
        public AccountInfo InitializeTestData()
        {
            var         _temp      = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
            XmlReader   xmlReader  = XmlReader.Create(@"..\XMLTestFiles\TPA_500.xml");
            var         tpa        = new TPAScaffold();
            var         serializer = new XmlSerializer(tpa.GetType());
            TPAScaffold input      = (TPAScaffold)serializer.Deserialize(xmlReader);
            TaxProfileAssistantController tpaController = new TaxProfileAssistantController();
            String      resultStr   = tpaController.Post(input);
            string      ID          = resultStr.Substring(38);
            AccountInfo accountInfo = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(ID);

            return(accountInfo);
        }
        [TestMethod()]//check modelstate if valid credentials are passed
        public void GetValidationErrorMessagesTestForValidModel()
        {
            //Arrange

            AvaTaxProfileAssistantHelperTests taxProfileAsstHelper = new AvaTaxProfileAssistantHelperTests();

            TryValidateModel(input.AccountCredentials);
            string ErrorString = "";

            //Act
            AvaTaxProfileAssistantHelper.GetValidationErrorMessages(ModelState, ref ErrorString);

            //Assert
            Assert.IsTrue(ModelState.IsValid, "Model state cannot be false when valid credentials are passed!!");
        }
        [TestMethod()]//Check if correct code is returned for state or country
        public void ParseCodeTestToCheckIfCorrectCodeIsReturnedForStateOrCountry()
        {
            //Arrange
            string state   = "MAHARASHTRA";
            string country = "CANADA";


            //Act
            var StateResult   = AvaTaxProfileAssistantHelper.ParseCode(state, ParseCodeCollection.State);
            var CountryResult = AvaTaxProfileAssistantHelper.ParseCode(country, ParseCodeCollection.Country);

            //Assert
            Assert.AreEqual("MH", StateResult, "Incorrect state code returned!!");
            Assert.AreEqual("CA", CountryResult, "Incorrect country code returned!!");
        }
        [TestMethod()]//Checks if data is inserted in database.
        public void InsertAccountInfoTestToCheckInsertionOfRecordInDatabase()
        {
            //Act
            var actualresult   = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            var expectedresult = AvaTaxProfileAssistantHelper.GetAccountInfo(actualresult.ID);

            //Assert
            Assert.AreEqual(expectedresult.ID, actualresult.ID, "Insertion of account information in database failed!!Incorrect Account ID!");
            Assert.AreEqual(expectedresult.AccountNumber, actualresult.AccountNumber, "Insertion of account information in database failed!!Incorrect AccountNumber!");
            Assert.AreEqual(expectedresult.UserName, actualresult.UserName, "Insertion of account information in database failed!!Incorrect Username!");
            Assert.AreEqual(expectedresult.Password, actualresult.Password, "Insertion of account information in database failed!!Incorrect Password!");
            Assert.AreEqual(expectedresult.LicenseKey, actualresult.LicenseKey, "Insertion of account information in database failed!!Incorrect License key!");
            Assert.AreEqual(expectedresult.CompanyCode, actualresult.CompanyCode, "Insertion of account information in database failed!!Incorrect Company Code!");
            Assert.AreEqual(expectedresult.Webservice, actualresult.Webservice, "Insertion of account information in database failed!!Incorrect WebService!");
        }
Beispiel #9
0
        [TestMethod]//Negative test to check if DoConnection Connects to service  if username is null or wrong
        public void HomepageController_DoConnectionMethodTestWithInvalidUsernameParameter()
        {
            //Arrange
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key              = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accInfo          = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
            accInfo.UserName = "";

            //Act
            homeController.DoConnection(ref IsConnected, ref IsChoseCompany, ref WhereToCollectTax, ref NexusWarning, accInfo);

            //Assert
            Assert.IsFalse(IsConnected, "Username Incorrect or Empty!!");
        }
Beispiel #10
0
        [TestMethod]//Negative test to check if DocConnection Connects to service  if LicenseKey is null or wrong
        public void HomepageController_DoConnectionMethodTest_With_Wrong_OR_Empty_LicenseKey()
        {
            //Arrange
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key                = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accInfo            = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
            accInfo.LicenseKey = "";

            //Act
            homeController.DoConnection(ref IsConnected, ref IsChoseCompany, ref WhereToCollectTax, ref NexusWarning, accInfo);

            //Assert
            Assert.IsFalse(IsConnected, "License Key Not Present or Wrong License Key is Entered!!");
        }
        [TestMethod()]//Check if the method returns correct number of mapped countries
        public void GetAvaERPCountryMappingTestToCheckIfItReturnsCorrectNumberOfMappedCountries()
        {
            //Arrange
            var AccountInfo      = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            int AvaERPSettingsID = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);

            //Act
            foreach (MappedCountry mc in input.AvaERPSettings.AddressValidation.MappedCountries)
            {
                AvaTaxProfileAssistantHelper.InsertAvaERPCountryMapping(AccountInfo.ID, AvaERPSettingsID, mc);
            }
            var result = AvaTaxProfileAssistantHelper.GetAvaERPCountryMapping(AccountInfo.ID);


            //Assert
            Assert.AreEqual(input.AvaERPSettings.AddressValidation.MappedCountries.Count, result.Count, "Incorrect number of mapped countries fetched!");
        }
        [TestMethod()]//Check if the method does not return an empty result
        public void GetAvaERPCountryMappingTestToCheckIfItDoesNotReturnEmptyResult()
        {
            //Arrange
            var AccountInfo      = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            int AvaERPSettingsID = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);

            //Act
            foreach (MappedCountry mc in input.AvaERPSettings.AddressValidation.MappedCountries)
            {
                AvaTaxProfileAssistantHelper.InsertAvaERPCountryMapping(AccountInfo.ID, AvaERPSettingsID, mc);
            }
            var result = AvaTaxProfileAssistantHelper.GetAvaERPCountryMapping(AccountInfo.ID);


            //Assert
            Assert.IsNotNull(result, "Empty result returned!!");
        }
        [TestMethod()]//Check if it returns a list of type AvaERPCountryMapping
        public void GetAvaERPCountryMappingTestToCheckIfItReturnsListOfAvaERPCountryMapping()
        {
            //Arrange
            var AccountInfo      = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            int AvaERPSettingsID = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);

            //Act
            foreach (MappedCountry mc in input.AvaERPSettings.AddressValidation.MappedCountries)
            {
                AvaTaxProfileAssistantHelper.InsertAvaERPCountryMapping(AccountInfo.ID, AvaERPSettingsID, mc);
            }
            var result = AvaTaxProfileAssistantHelper.GetAvaERPCountryMapping(AccountInfo.ID);


            //Assert
            Assert.IsInstanceOfType(result, typeof(List <AvaERPCountryMapping>), "Incorrect result type returned!!");
        }
Beispiel #14
0
        [TestMethod]//Negative test to check if DocConnection Connects to service  if Webservice is null or wrong
        public void HomepageController_DoConnectionMethodTest_Without_WebserviceURL()
        {
            //Arrange
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key                = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accInfo            = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
            accInfo.Webservice = "";


            //Act
            homeController.DoConnection(ref IsConnected, ref IsChoseCompany, ref WhereToCollectTax, ref NexusWarning, accInfo);

            //Assert
            Assert.IsFalse(IsConnected, "Webservice URL is not provided!!");
        }
Beispiel #15
0
        [TestMethod]//Positive test to check that DoConnection sets all boolean parameters to true when account information is correctly passed to it
        public void HomepageController_DoConnectionMethodTestWithAllParameters()
        {
            //Arrange
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key     = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accInfo = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);

            //Act
            homeController.DoConnection(ref IsConnected, ref IsChoseCompany, ref WhereToCollectTax, ref NexusWarning, accInfo);

            //Assert
            Assert.IsTrue(IsConnected, "Service Connection Failed!");
            Assert.IsTrue(IsChoseCompany, "Company not Chosen!");
            Assert.IsTrue(WhereToCollectTax, "WhereToCollectTax not specified!");
            Assert.IsTrue(NexusWarning, "NexusWarning is not set to true!");
        }
Beispiel #16
0
        [TestInitialize]//Initializes data required for each test and runs once per test method.
        public void InitializeData()
        {
            //Arrange
            accountInfo = new AccountInfo();

            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_500.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);

            tpaController = new TaxProfileAssistantController();
            tpaController.ControllerContext = new ControllerContext();
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key         = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accountInfo = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
        }
        [TestMethod()]//check modelstate and if false return errorstring
        public void GetValidationErrorMessagesTestForInvalidModel()
        {
            //Arrange
            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_1000_AccountCredentialsMissing.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);
            AvaTaxProfileAssistantHelperTests taxProfileAsstHelper = new AvaTaxProfileAssistantHelperTests();

            TryValidateModel(input.AccountCredentials);
            string ErrorString = "";

            //Act
            AvaTaxProfileAssistantHelper.GetValidationErrorMessages(ModelState, ref ErrorString);

            //Assert
            Assert.AreEqual(false, ModelState.IsValid, "Model state cannot be true when invalid credentials are passed!!");
        }
Beispiel #18
0
        [TestMethod]//Test to check if DoConnection throws an exception if accountnumber is not passed
        public void HomepageController_DoConnectionMethod_ThrowsExceptionTest()
        {
            //Arrange
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key     = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accInfo = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
            accInfo.AccountNumber = "";
            Exception e = new Exception();

            //Act

            homeController.DoConnection(ref IsConnected, ref IsChoseCompany, ref WhereToCollectTax, ref NexusWarning, null);

            //Assert

            AssertFailedException.Equals("Object reference not set to an instance of an object.", e);
        }
        [TestMethod()]//Check if it returns the correct accountInfo details.
        public void GetAccountInfoBySecureKeyTestToCheckIfCorrectAccountInfoDetailsAreFetched()
        {
            //Arrange
            TaxProfileAssistantController tpaController = new TaxProfileAssistantController();

            tpaController.ControllerContext = new ControllerContext();
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");

            //Act
            AccountInfo accInfo = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);

            //Assert
            Assert.AreEqual(input.AccountCredentials.AccountNumber, accInfo.AccountNumber, "Incorrect AccountNumber returned!!");
            Assert.AreEqual(input.AccountCredentials.UserName, accInfo.UserName, "Incorrect UserName returned!!");
            Assert.AreEqual(input.AccountCredentials.Password, accInfo.Password, "Incorrect Password returned!!");
            Assert.AreEqual(input.AccountCredentials.LicenseKey, accInfo.LicenseKey, "Incorrect LicenseKey returned!!");
        }
        [TestInitialize]//Initializes data required for each test and runs once per test method.
        public void InitializeData()
        {
            accountInfo = new AccountInfo();
            XmlReader xmlReader  = XmlReader.Create(@"..\XMLTestFiles\TPA_500.xml");
            var       tpa        = new TPAScaffold();
            var       serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);

            tpaController = new TaxProfileAssistantController();
            tpaController.ControllerContext = new ControllerContext();
            string resultstr = tpaController.Post(input);
            string key       = resultstr.Substring(38);

            key                     = key.Replace(Constants.APPLICATION_URL_DUMMY_TEXT, "/");
            accountInfo             = AvaTaxProfileAssistantHelper.GetAccountInfoBySecureKey(key);
            createCompanyController = new CreateCompanyController();
            accountService          = new AccountService(accountInfo.Webservice, accountInfo.UserName, accountInfo.Password, accountInfo.AccountNumber, accountInfo.LicenseKey, accountInfo.ERPName);
            TempData                = new TempDataDictionary();
            createCompanyController.TempData.Add("AccountInfo", accountInfo);
            createCompanyController.TempData.Add("AccountService", accountService);
        }
        [TestMethod()]//Check if the method successfully inserts customer records in database
        public void InsertCustomersTestToCheckInsertionOfCustomerRecordsInDatabase()
        {
            //Arrange
            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_New.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);

            var AccountInfo   = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            var AvaERPSetting = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);


            //Act
            foreach (AvaCustomer cust in input.AvaERPSettings.Customers)
            {
                var actualResult = AvaTaxProfileAssistantHelper.InsertCustomers(cust, AccountInfo.ID, AvaERPSetting);

                //Assert
                Assert.AreEqual(true, actualResult, "Customer Insertion failed!!");
            }
        }
        [TestMethod()]//Check if it returns correct number of customers as inserted from xml.
        public void GetCustomersListTestToCheckIfItReturnsCorrectNumberOfCustomers()
        {
            //Arrange
            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_New.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);

            var AccountInfo   = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            var AvaERPSetting = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);


            //Act
            foreach (AvaCustomer cust in input.AvaERPSettings.Customers)
            {
                var actualResult = AvaTaxProfileAssistantHelper.InsertCustomers(cust, AccountInfo.ID, AvaERPSetting);
            }

            var Result = AvaTaxProfileAssistantHelper.GetCustomersList(AccountInfo.ID);

            Assert.AreEqual(Result.Count, input.AvaERPSettings.Customers.Count, "Incorrect number of customers returned!!");
        }
        [TestMethod()]//Check if it returns a list of AvaERPSettingsOtherDetails.
        public void GetAvaERPSettingOtherDetailsTestToCheckReturnType()
        {
            xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_New.xml");
            var tpa        = new TPAScaffold();
            var serializer = new XmlSerializer(tpa.GetType());

            input = (TPAScaffold)serializer.Deserialize(xmlReader);
            var AccountInfo      = AvaTaxProfileAssistantHelper.InsertAccountInfo(input.AccountCredentials);
            int AvaERPSettingsID = AvaTaxProfileAssistantHelper.InsertAvaERPSetting(input.AvaERPSettings, AccountInfo.ID);

            //Act

            foreach (EntityNameCode ec in input.AvaERPSettings.MapItemCodes.NonTaxableItems.Items)
            {
                AvaTaxProfileAssistantHelper.InsertEntityNameCode(AccountInfo.ID, AvaERPSettingsID, ec, Constants.AVAERP_SETTINGS_ITEMS);
            }

            var result = AvaTaxProfileAssistantHelper.GetAvaERPSettingOtherDetails(AccountInfo.ID);

            //Assert

            Assert.IsInstanceOfType(result, typeof(List <AvaERPSettingsOtherDetails>), "Incorrect result type returned!!");
        }