[TestInitialize]//Initializes data required for each test and runs once per test method. public void InitializeData() { //Arrange 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); nexusController = new NexusSetupController(); accountService = new AccountService(accountInfo.Webservice, accountInfo.UserName, accountInfo.Password, accountInfo.AccountNumber, accountInfo.LicenseKey, accountInfo.ERPName); TempData = new TempDataDictionary(); nexusController.TempData.Add("AccountInfo", accountInfo); nexusController.TempData.Add("AccountService", accountService); }
[TestMethod()]//Checks if Index method returns existing companies view public void ExistingCompanyController_IndexTest_CheckIfItReturnsCorrectView() { //Arrange AccountInfo accountInfo = new AccountInfo(); TPAScaffold input = new TPAScaffold(); TaxProfileAssistantController tpaController = new TaxProfileAssistantController(); XmlReader xmlReader = XmlReader.Create(@"..\XMLTestFiles\TPA_500.xml"); var tpa = new TPAScaffold(); var serializer = new XmlSerializer(tpa.GetType()); input = (TPAScaffold)serializer.Deserialize(xmlReader); 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); ExistingCompanyController existingCompany = new ExistingCompanyController(); TempDataDictionary TempData = new TempDataDictionary(); existingCompany.TempData.Add("AccountInfo", accountInfo); //Act var result = existingCompany.Index() as ViewResult; //Assert: Checks if Company Information is returned Assert.IsTrue(result.TempData.Count > 0); Assert.IsInstanceOfType(result, typeof(ViewResult)); }
[TestInitialize]//Initializes data required for each test and runs once per test method. public void InitializeData() { //Arrange avaSetupReportController = new AvaSetupReportController(); 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); accountService = new AccountService(accountInfo.Webservice, accountInfo.UserName, accountInfo.Password, accountInfo.AccountNumber, accountInfo.LicenseKey, accountInfo.ERPName); TempDataDictionary TempData = new TempDataDictionary(); avaSetupReportController.TempData.Add("AccountInfo", accountInfo); avaSetupReportController.TempData.Add("AccountService", accountService); Constants.SESSION_KEY_SELECTED_COMPANY = "4.1 Dev Company"; avaSetupReportController.TempData.Add(Constants.SESSION_KEY_SELECTED_COMPANY, "4.1 Dev Company"); avaSetupReportController.TempData.Add(TaxProfileAssistant.Utils.Constants.SESSION_KEY_ERP_NAME, accountInfo.ERPName); avaSetupReportController.TempData.Add(TaxProfileAssistant.Utils.Constants.SESSION_KEY_COMPANY_NAME, "Systems of America"); }
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]//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]//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!!"); }
[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!!"); }
[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!"); }
[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); }
[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 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!!"); }