public void SetupChannelShouldThrowTestPlatformExceptionIfRequestCancelledPostHostLaunchDuringWaitForHandlerConnection() { SetupTestHostLaunched(true); this.mockRequestSender.Setup(rs => rs.WaitForRequestHandlerConnection(this.connectionTimeout, It.IsAny <CancellationToken>())).Returns(false); var cancellationTokenSource = new CancellationTokenSource(); this.mockTestHostManager.Setup(rs => rs.LaunchTestHostAsync(It.IsAny <TestProcessStartInfo>(), It.IsAny <CancellationToken>())).Callback(() => cancellationTokenSource.Cancel()); var operationManager = new TestableProxyOperationManager(this.mockRequestData.Object, this.mockRequestSender.Object, this.mockTestHostManager.Object, cancellationTokenSource); var message = Assert.ThrowsException <TestPlatformException>(() => operationManager.SetupChannel(Enumerable.Empty <string>(), this.defaultRunSettings)).Message; StringAssert.Equals("Cancelling the operation as requested.", message); }
public void ConfigEndpointTest() { string url = "https://configunittest.intacct.com/ia/xml/xmlgw.phtml"; SdkConfig config = new SdkConfig() { EndpointUrl = url }; Endpoint endpoint = new Endpoint(config); Assert.AreEqual(url, endpoint.Url); StringAssert.Equals(url, endpoint); }
public void CredsFromArrayTest() { SdkConfig config = new SdkConfig { SessionId = "faKEsesSiOnId..", EndpointUrl = "https://p1.intacct.com/ia/xml/xmlgw.phtml" }; SessionCredentials sessionCreds = new SessionCredentials(config, senderCreds); Assert.AreEqual("faKEsesSiOnId..", sessionCreds.SessionId); StringAssert.Equals("https://p1.intacct.com/ia/xml/xmlgw.phtml", sessionCreds.Endpoint); Assert.IsInstanceOfType(sessionCreds.SenderCreds, typeof(SenderCredentials)); }
public void UnspecifiedSolutionNameWithNoTargetProjectsUsesFolderName() { options = new SlnGenerationOptions(WorkingDirectory); StringAssert.Equals("WorkingDir", options.SolutionName); options = new SlnGenerationOptions(Path.Combine(WorkingDirectory, "SlumJim")); StringAssert.Equals("SlumJim", options.SolutionName); options = new SlnGenerationOptions(Path.Combine(WorkingDirectory, "SlumJim") + Path.DirectorySeparatorChar + Path.DirectorySeparatorChar); StringAssert.Equals("SlumJim", options.SolutionName); options = new SlnGenerationOptions(Path.DirectorySeparatorChar.ToString()); StringAssert.Equals("SlimJim", options.SolutionName); }
public void JobLocationOverwrittenTitleTest() { //arrnge EmployeeClass myEmployee = new EmployeeClass(12); myEmployee.JobTitle = "Staff"; //act string jobLocation = myEmployee.JobLocation(); //assert //check if correct location is returned StringAssert.Equals("Boston", jobLocation); }
public void TestMethod6() { string content = ""; if (File.Exists("test10.txt")) { content = File.ReadAllText("test10.txt"); } else { content = "文件名不正确请检查..."; } StringAssert.Equals("文件名不正确请检查...", content); }
public void AddBookTestWithNullTitle() { var testReader = new StubIApplicationReader() { LoginGet = () => { return(testLogin); }, PasswordGet = () => { return(testPassword); }, BookCollectionGet = () => { return(new List <IApplicationBook>()); } }; string nullTitle = null; manager.AddReader(testReader); manager.AddBook(testReader, nullTitle, testAuthor); StringAssert.Equals(manager.Books[0].Title, nullTitle); }
///Amer Beso - 68-ST - implementacija public void TestPromjenaSamoGodine() { Skolovanje s = new Skolovanje(); LicniPodaci l1 = new LicniPodaci("Amer", "Beso", "Travnik", "*****@*****.**", "image.jpeg", "1231231231233", Spol.Muško, DateTime.Now); Student s1 = new Student("amer12", "beso2332", l1, null, s); //indeks prije promjene skolovanja String indeksPocetni = s1.Skolovanje.BrojIndeksa; s1.PromjenaInformacijaOSkolovanju("Elektrotehnički fakultet", 3, 1); StringAssert.Equals(s1.Skolovanje.MaticniFakultet, "Elektrotehnički fakultet"); Assert.AreEqual(s1.Skolovanje.BrojIndeksa, indeksPocetni);//sada ce indeksi biti isti Assert.AreEqual(s1.Skolovanje.CiklusStudija, 1); Assert.AreEqual(s1.Skolovanje.GodinaStudija, 3); }
public async Task ShouldReceive401OnDuplicateAuthorizeRequest() { var client = new HttpClient(); var url = string.Concat(_address, "/api/values/5"); var result = await client.GetAsync(url); var wwwAuthenticate = result.Headers.WwwAuthenticate.First(); Assert.AreEqual(HttpStatusCode.Unauthorized, result.StatusCode); StringAssert.Equals(wwwAuthenticate.Scheme, "AuthAPI"); var responsePayload = new ResponsePayload(wwwAuthenticate.Parameter); var requestPayload = new RequestPayload { ClientId = "TestAPI", Identifier = responsePayload.Identifier, RequestCount = string.Format("{0:D8}", int.Parse(responsePayload.RequestCount) + 1), UserName = "******" }; var dataPayload = new DataPayload { ClientId = "TestAPI", Method = "GET", Password = "******", RequestBodyBase64 = string.Empty, RequestURI = "/api/values/5", UserName = "******" }; var authHeader = new AuthHeader { Data = dataPayload, Request = requestPayload }; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("AuthAPI", authHeader.ToAuthorizationHeader("QiU6bSt3anE2OURfX3IsKlVZen05K1tBLW5AQ1x1d0xIXVZwaGE7Zj83QTc0ZXthVy9aWV9UZ0tUcnRUVEQ6d2JxTEhGOi9fMitBfiNZOS5NXHlyJzNnNSl1VzxNQExkQXtHJEQ+fWElMkMhWUJhLT8kbUFeQERWa310J2N+NkQ=")); result = await client.GetAsync(url); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); Assert.AreEqual(await result.Content.ReadAsAsync <string>(), "value"); result = await client.GetAsync(url); Assert.AreEqual(HttpStatusCode.Unauthorized, result.StatusCode); }
public void Player_Default() { // Expect the following fields of creature to have default values. StringAssert.Equals("player", player.id); Assert.IsNull(player.name); Assert.AreEqual(0, player.HP); Assert.AreEqual(5u, player.AttackRating); Assert.IsNull(player.location); Assert.IsNull(player.dungeon); Assert.AreEqual(100, player.HPbase); Assert.IsFalse(player.accelerated); Assert.AreEqual(0u, player.KillPoint); Assert.IsNotNull(player.bag); Assert.AreEqual(0, player.bag.Count); }
public void GetFormalProposalWithInvalidOpportunity_ThenBadRequestIsReturned() { var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new StringContent("") }; var mockGraphHelper = GetGraphSdkHelper(response).Object; var controller = new DocumentController(mockGraphHelper, ConfigurationProvider); var result = controller.GetFormalProposalAsync(null).GetAwaiter().GetResult() as BadRequestObjectResult; Assert.IsNotNull(result); StringAssert.Equals("id is required", result.Value.ToString()); }
public void WhenUpdateIsCalledWithInvalidDocumentData_ThenBadRequestIsReturned() { var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK) { Content = new StringContent("") }; var mockGraphHelper = GetGraphSdkHelper(response).Object; var controller = new DocumentController(mockGraphHelper, ConfigurationProvider); var result = controller.UpdateTaskAsync("id", null).GetAwaiter().GetResult() as BadRequestObjectResult; Assert.IsNotNull(result); StringAssert.Equals("documentData is required", result.Value.ToString()); }
public void CredsFromArrayTest() { SdkConfig config = new SdkConfig { SenderId = "testsenderid", SenderPassword = "******", EndpointUrl = "https://unittest.intacct.com/ia/xmlgw.phtml" }; SenderCredentials senderCreds = new SenderCredentials(config); Assert.AreEqual("testsenderid", senderCreds.SenderId); Assert.AreEqual("pass123!", senderCreds.Password); StringAssert.Equals("https://unittest.intacct.com/ia/xml/xmlgw.phtml", senderCreds.Endpoint); }
public void protectThenUnprotectTwice() { string ip = "125.23.53.124"; Contact contact = new Contact(1, "Michael", ip); string returnedIp = contact.getIPString(); //should unprotect, return, then reprotect returnedIp = contact.getIPString(); //should do the same as above bool pass = StringAssert.Equals(ip, returnedIp); if (!pass) { Assert.Fail("ip not protected and unprotected succesfully"); } }
public void EnvVariableEndpointTest() { string url = "https://envunittest.intacct.com/ia/xml/xmlgw.phtml"; Environment.SetEnvironmentVariable("INTACCT_ENDPOINT_URL", url); SdkConfig config = new SdkConfig(); Endpoint endpoint = new Endpoint(config); Assert.AreEqual(url, endpoint.Url); StringAssert.Equals(url, endpoint); Environment.SetEnvironmentVariable("INTACCT_ENDPOINT_URL", null); }
public void MiCuenta() { driverFF.Navigate().GoToUrl("http://juntoz-qa.com/"); driverFF.FindElement(By.XPath("//div[@id='header-juntoz']/nav/div/div[2]/div/div/div/div/ul/li[3]/span/a/span/span[2]/span")).Click(); driverFF.FindElement(By.CssSelector("li > h1.h1-logo.ng-scope > a.logo")).Click(); driverFF.FindElement(By.Id("btncartitem")).Click(); Assert.IsTrue(IsElementPresent(By.Id("btnaccount"))); StringAssert.Equals("Mi Hola Cuenta", driverFF.FindElement(By.Id("btnaccount")).Text); driverFF.FindElement(By.Id("btnaccount")).Click(); Assert.IsTrue(IsElementPresent(By.XPath("//div[@id='header-juntoz']/nav/div/div[2]/div/div/div/div/ul/li/div/div[2]/div/div/div/div/button"))); Assert.AreEqual("Identificarse", driverFF.FindElement(By.XPath("//div[@id='header-juntoz']/nav/div/div[2]/div/div/div/div/ul/li/div/div[2]/div/div/div/div/button")).Text); try { Assert.IsTrue(Regex.IsMatch(driverFF.FindElement(By.CssSelector("p.text-new-customer > span.ng-scope")).Text, "^exact:¿Eres cliente nuevo[\\s\\S]$")); } catch (AssertFailedException) { } Assert.IsTrue(IsElementPresent(By.CssSelector("a.text-new-customer.ng-scope"))); Assert.AreEqual("Empieza aquí.", driverFF.FindElement(By.CssSelector("a.text-new-customer.ng-scope")).Text); }
public void SshClient_WriteTextToFileAndReadIt_WritedTextShouldBeSameAsReadText(string filename) { using (var SshClient = new SshClient(_SshCredentials.Host, _SshCredentials.Login, _SshCredentials.Password)) { SshClient.Connect(); string textToWrite = $"KasperskyLab_LovesYou_Rand:{RandomNumber}"; using (var cmd = SshClient.CreateCommand($"echo '{textToWrite}' > ./{filename} && cat ./{filename} && rm {filename}")) { cmd.Execute(); string cmdOutput = cmd.Result; SshClient.Disconnect(); StringAssert.Equals(cmdOutput, textToWrite + "\n"); } } }
public void MiCarrito() { driverFF.Navigate().GoToUrl("http://juntoz-qa.com/"); Assert.IsTrue(IsElementPresent(By.Id("btncartitem"))); StringAssert.Equals("Mi Carrito", driverFF.FindElement(By.Id("btncartitem")).Text); driverFF.FindElement(By.Id("btncartitem")).Click(); Assert.IsTrue(IsElementPresent(By.XPath("//div[@id='header-juntoz']/nav/div/div[2]/div/div/div/div/ul/li[2]/div/div[2]/div/div/div[2]"))); Assert.AreEqual("Tu carrito de compras está vacío.", driverFF.FindElement(By.CssSelector("label.ng-scope")).Text); Assert.AreEqual("Empieza a usarlo, llénalo con tus marcas preferidas.", driverFF.FindElement(By.CssSelector("p.ng-scope")).Text); Assert.IsTrue(IsElementPresent(By.LinkText("Ver carrito"))); Assert.AreEqual("Ver carrito", driverFF.FindElement(By.LinkText("Ver carrito")).Text); Assert.AreEqual("Si ya está registrado, ingresa aquí:", driverFF.FindElement(By.CssSelector("div.popover-cart-header__content.ng-scope > p > span.ng-scope")).Text); Assert.IsTrue(IsElementPresent(By.LinkText("Mi cuenta"))); Assert.AreEqual("Mi cuenta", driverFF.FindElement(By.LinkText("Mi cuenta")).Text); }
public void CancelarOrden() { driver.Navigate().GoToUrl("http://juntoz-qa.com/"); driver.FindElement(By.Id("btnaccount")).Click(); driver.FindElement(By.Id("btnaccount")).Click(); driver.FindElement(By.XPath("//div[@id='header-juntoz']/nav/div/div[2]/div/div/div/div/ul/li/div/div[2]/div/div/div/div/button")).Click(); driver.FindElement(By.Id("btnaccount")).Click(); Thread.Sleep(1000); driver.FindElement(By.Name("userEmail")).Clear(); driver.FindElement(By.Name("userEmail")).SendKeys("*****@*****.**"); driver.FindElement(By.Name("password")).Clear(); driver.FindElement(By.Name("password")).SendKeys("denisse"); driver.FindElement(By.Id("btnLogin")).Click(); Thread.Sleep(3000); driver.FindElement(By.Id("btnaccount")).Click(); driver.FindElement(By.LinkText("Mis Órdenes")).Click(); driver.FindElement(By.Id("btnaccount")).Click(); Thread.Sleep(3000); //Modificar Orden driver.FindElement(By.Id("160928193803")).Click(); Thread.Sleep(1000); driver.FindElement(By.CssSelector("i.fa.fa-eye")).Click(); Thread.Sleep(3000); Assert.AreEqual("Nuevo", driver.FindElement(By.XPath("//td[7]/span")).Text); Assert.IsTrue(IsElementPresent(By.CssSelector("button.btn.bg-navy"))); Assert.AreEqual("Cancelar orden", driver.FindElement(By.CssSelector("button.btn.bg-navy")).Text); driver.FindElement(By.CssSelector("button.btn.bg-navy")).Click(); Assert.IsTrue(IsElementPresent(By.CssSelector("h3.modal-title.ng-binding"))); Assert.IsTrue(IsElementPresent(By.CssSelector("h3.modal-title.ng-binding"))); Assert.AreEqual("Cancelar orden", driver.FindElement(By.CssSelector("h3.modal-title.ng-binding")).Text); Assert.AreEqual("Lamentamos tu decisión.", driver.FindElement(By.CssSelector("small")).Text); try { Assert.IsTrue(Regex.IsMatch(driver.FindElement(By.CssSelector("h4 > small")).Text, "^exact:¿Cuál es el motivo de tu cancelación[\\s\\S]$")); } catch (AssertFailedException) { } Assert.IsTrue(IsElementPresent(By.XPath("//select"))); StringAssert.Equals("Cambio de direcciónNo podré esperar el tiempo de entregaCambio de productoYa no tengo dinero para pagarLo encontré mas barato en otra tiendaTengo un cupón de descuentoCambiar método de pagoLo compre en otra tiendaQuiero aprovechar promoción vigenteNo reconozco la compra realizada", driver.FindElement(By.XPath("//select")).Text); Assert.IsTrue(IsElementPresent(By.XPath("//div[3]/button"))); Assert.AreEqual("Cerrar", driver.FindElement(By.XPath("//div[3]/button")).Text); Assert.IsTrue(IsElementPresent(By.CssSelector("button.close"))); Assert.AreEqual("x", driver.FindElement(By.CssSelector("button.close")).Text); new SelectElement(driver.FindElement(By.XPath("//select"))).SelectByText("Cambio de dirección"); Assert.IsTrue(IsElementPresent(By.XPath("//div[3]/button[2]"))); Assert.AreEqual("Cancelar", driver.FindElement(By.XPath("//div[3]/button[2]")).Text); driver.FindElement(By.XPath("//div[3]/button[2]")).Click(); Assert.AreEqual("Cancelado", driver.FindElement(By.XPath("//div[@id='body-juntoz']/div[2]/div/div/div/div/div/div/div/div[2]/div/div/div/div/div[3]/div/ul/li/div/div/div/table/tbody/tr/td[7]/span")).Text); driver.Navigate().Refresh(); }
public void SearchByProductNameTest() { OrderService orderService = new OrderService(); Order order1 = new Order("1", "1", "1", 1); orderService.orders.Add(order1); orderService.SearchByProductName("1"); try { orderService.SearchByProductName("2"); } catch (Exception e) { StringAssert.Equals(e.Message, "错误!未找到该订单"); } }
public void IsUniqueTest() { OrderService orderService = new OrderService(); Order order1 = new Order("1", "1", "1", 1); orderService.orders.Add(order1); orderService.IsUnique("2"); try { orderService.IsUnique("1"); } catch (Exception e) { StringAssert.Equals(e.Message, "错误!订单号已存在"); } }
public void DistrictNameTesting() // Method for testing District's name { List <string> districtName = new List <string>() { "Tallinna Haabersti, Põhja-Tallinna ja Kristiine linnaosa", "Tallinna Kesklinna, Lasnamäe ja Pirita linnaosa", "Tallinna Mustamäe ja Nõmme linnaosa", "Harju- ja Raplamaa", "Hiiu-, Lääne- ja Saaremaa", "Lääne-Virumaa", "Ida-Virumaa", "Järva- ja Viljandimaa", "Jõgeva- ja Tartumaa", "Tartu linn", "Võru-, Valga- ja Põlvamaa", "Pärnumaa" }; vote.FillDictionaryDistrictName(); for (int i = 1; i < vote._districtVotesSum.Count; i++) { StringAssert.Equals(vote._districtName[i]._districtName, districtName[i - 1]); } }
public void Class_Employee__Set() { //arange(initiating an object) EmployeeClass myEmployee = new EmployeeClass("Yulia", "Svitukha"); //act(call methods if needed) string a = myEmployee.ReturnEmployee(); string b = myEmployee.ReturnEmployeeSorted(); //assert //Check that correct employee is returned StringAssert.Equals(myEmployee.FirstName, "Yulia"); StringAssert.Equals(a, "Yulia Svitukha"); StringAssert.Equals(b, "Svitukha, Yulia"); }
public void ParseStringForKeyValue_Tests() { string key = "testkey"; string value = "value"; string space = key + ": " + value; string nospace = key + ":" + value; string garbage = "asdsadsad" + key + ":" + value; string spaceBefore = " " + key + ":" + value; string emptyStr = " "; string actual = " " + space; string[] arr = new string[] { space, nospace, garbage, spaceBefore, emptyStr, actual }; int index = 0; string spaceResult; Assert.IsTrue(Utils.StringArray.ParseStringForKeyValue(arr, key, ref index, out spaceResult)); StringAssert.Equals(spaceResult, value); Assert.AreEqual(1, index); string nospaceResult; Assert.IsTrue(Utils.StringArray.ParseStringForKeyValue(arr, key, ref index, out nospaceResult)); StringAssert.Equals(nospaceResult, value); Assert.AreEqual(2, index); string garbageResult; Assert.IsTrue(Utils.StringArray.ParseStringForKeyValue(arr, key, ref index, out garbageResult)); StringAssert.Equals(garbageResult, value); Assert.AreEqual(3, index); string spaceBeforeResult; Assert.IsTrue(Utils.StringArray.ParseStringForKeyValue(arr, key, ref index, out spaceBeforeResult)); StringAssert.Equals(spaceBeforeResult, value); Assert.AreEqual(4, index); string twoLineResult; Assert.IsTrue(Utils.StringArray.ParseStringForKeyValue(arr, key, ref index, out twoLineResult)); StringAssert.Equals(twoLineResult, value); Assert.AreEqual(6, index); }
//implementacija - Faris Colakovic public void TestLicniPodaciKlasa() { Korisnik k; Skolovanje s = new Skolovanje(); DateTime d = DateTime.Now; LicniPodaci l = new LicniPodaci("Faris", "Colakovic", "Zenica", "*****@*****.**", "image.jpeg", "1231231231233", Spol.Muško, d); k = new Student("colakovic231", "colakovic231", l, null, s); StringAssert.Equals(l.Ime, "Faris"); StringAssert.Equals(l.Prezime, "Colakovic"); StringAssert.Equals(l.MjestoRodjenja, "Zenica"); Assert.AreEqual(l.Spol, Spol.Muško); StringAssert.Equals(l.Email, "*****@*****.**"); StringAssert.Equals(l.Slika, "image.jpeg"); StringAssert.Equals(l.JMBG, "1231231231233"); Assert.AreEqual(l.DatumRodjenja, d); }
public void ReadFileThrowFileNotFoundException() { //Arrange string FileName = @"C:\Users\panda\Downloads\Super Mario Bros. (USA).nes"; NESEmu.CartridgeReader cartReader = new CartridgeReader(FileName); //Act try { NESEmu.Cartridge cart = cartReader.readCart(); } catch (FileNotFoundException exception) { //Assert StringAssert.Equals(exception, new FileNotFoundException()); } }
public void BeforeEachTest_should_be_called_before_each_scenario_test() { var scenarios = new[] { "A", "B", "C", "D" }; var callbackValues = new List <string>(); int index = -1; new ScenarioTester <string>(scenarios) .BeforeEachTest(scenario => { index++; Assert.AreEqual(scenarios[index], scenario); callbackValues.Add(scenario); }) .TestEach(scenario => { }); StringAssert.Equals(string.Join("", scenarios), string.Join("", callbackValues.ToArray())); }
public void CredsFromArrayTest() { SdkConfig config = new SdkConfig { CompanyId = "testcompany", UserId = "testuser", UserPassword = "******" }; LoginCredentials loginCreds = new LoginCredentials(config, senderCreds); Assert.AreEqual("testcompany", loginCreds.CompanyId); Assert.AreEqual("testuser", loginCreds.UserId); Assert.AreEqual("testpass", loginCreds.Password); StringAssert.Equals("https://api.intacct.com/ia/xml/xmlgw.phtml", loginCreds.Endpoint); Assert.IsInstanceOfType(loginCreds.SenderCreds, typeof(SenderCredentials)); }
public void SearchByOrderIDTest() { OrderService orderService = new OrderService(); Order o = new Order(); o.OrderID = "001"; orderService.orderList.Add(o); orderService.SearchByOrderID("001"); try { orderService.SearchByOrderID("002"); } catch (Exception e) { StringAssert.Equals(e.Message, "错误!没有该订单号订单!"); } }
public void SearchByCustomerTest() { OrderService orderService = new OrderService(); Order o = new Order(); o.Customer = "lll"; orderService.orderList.Add(o); orderService.SearchByCustomer("lll"); try { orderService.SearchByCustomer("2"); } catch (Exception e) { StringAssert.Equals(e.Message, "错误!找不到该客户的订单"); } }