public void Amazon_AddToWishList_Scenario() { RunTest(() => { App.Reporter.TestDescription = "Use Case #2: Removing item from cart."; App.Reporter.TestStep = "Open the Amazon website"; App.Amazon.OpenSite(); App.Reporter.TestStep = "Search for product X using the text box."; App.Amazon.SearchForProduct("headphones"); App.Reporter.TestStep = "Click on any item from the list."; Random number = new Random(); App.Amazon.PickItemFromResult(number.Next(0, 10)); App.Reporter.TestStep = "Add item to wishlist."; App.Amazon.WaitForScreen(App.Amazon.AddToCartBtn); App.Amazon.AddToWishListBtn.ScrollIntoView(); App.Amazon.AddToWishListBtn.Click(); App.Reporter.TestStep = "Validate that item was added to wish list."; App.Amazon.WaitForScreen(App.Amazon.AddToListWindow); Assertions.AreEqual(true, App.Amazon.AddToListSuccessMsg.GetTextFromElement().Contains("1 item added to Shopping List"), "Validating that item was added to Wish List."); }); }
public void TC100_ValidateContrainMovementDrag() { DemoQaHome hm = new DemoQaHome(dr); //Validate home page title Assertions.AreEqual <String>("Home", hm.pageHeading.Text, "Validating Home page heading"); //Take screenshot SeleniumScreenshot.TakeScreenShot("Homescreen.png"); //Click on Draggable side Menu hm.menuItem.interactionMenu.Draggable.ClickOnIt(); //Validate Draggable default page title DefaultDraggable dd = new DefaultDraggable(dr); Assertions.AreEqual <string>("Draggable", dd.pageHeading.Text, "Validating Draggable Page heading"); //Take screenshot SeleniumScreenshot.TakeScreenShot("DraggableDefautl.png"); //Click on constrain movement dd.subMenu.ConstrainMovement.ClickOnIt(); //Take screenshot SeleniumScreenshot.TakeScreenShot("ConstrainMovementDefault.png"); //Perform actions DraggableContraintMovement cons = new DraggableContraintMovement(dr); cons.MoveElementBy(cons.horizontalDrag, 100, 0); cons.MoveElementBy(cons.verticalDrag, 0, 50); cons.MoveElementBy(cons.constrainDrag, 100, 100); SeleniumScreenshot.TakeScreenShot("AfterContrainMovement.png"); test.Log(LogStatus.Pass, "Drag actions performed"); }
public void Amazon_AddingFromCart_UC1() { RunTest(() => { App.Reporter.TestDescription = "Use Case #1: Adding item to cart."; App.Reporter.TestStep = "Open the Amazon website"; App.Amazon.OpenSite(); App.Reporter.TestStep = "Search for product X using the text box."; App.Amazon.SearchForProduct("headphones"); App.Reporter.TestStep = "Validate that at least one result was obtained."; App.Amazon.WaitForScreen(App.Amazon.ResultsList); Assertions.AreEqual(App.Amazon.ResultsSection.Text.Contains("headphones"), true, "Validating that results with the word 'headphones were returned.'"); App.Reporter.TestStep = "Click on any item from the list."; Random number = new Random(); App.Amazon.PickItemFromResult(number.Next(10)); App.Reporter.TestStep = "Add item to cart."; App.Amazon.WaitForScreenToLoad(App.Amazon.AddToCartBtn); App.Amazon.AddToCartBtn.Click(); App.Driver.WaitForActionToComplete(() => { return App.Amazon.CartItemCount.GetTextFromElement().Equals("1"); }, timeout: 5, idleInterval: 10); App.Reporter.TestStep = "Verify that item was added to the Shopping cart"; App.Amazon.CartBtn.Click(); App.Amazon.WaitForScreenToLoad(App.Amazon.ShoppingCartSection); Assertions.AreEqual(true, App.Amazon.ValidateItemExistsInCart(1), "Validate that item was added to the shopping cart."); }); }
public void TC102_TitleValidation() { DemoQaHome dm = new DemoQaHome(dr); SeleniumScreenshot.TakeScreenShot("DemoHome"); //Validate Page title Assertions.AreEqual <string>("Home", dm.pageHeading.Text, "Validating Home page heading"); }
public void Values_Returns_All_Values(string queryString, bool caseSensitiveKey, string[] expected) { var dictionary = new QueryStringDictionary(queryString, caseSensitiveKey); var actual = dictionary.Values.ToArray(); Assertions.AreEqual(expected, actual); }
public void AutoConfigFileExists() { RunTest(() => { App.Reporter.TestDescription = "Read my XML."; App.Reporter.TestStep = "Get deployment directory"; Assertions.AreEqual(AutoConfig.XmlFilePath, AutoConfig.XmlFilePath, "File paths are not the same."); Assertions.AreEqual("", AutoConfig.XmlFilePath, "File paths are not the same."); }); }
public void ReturnBytes_Sets_Environment_Up_Correctly() { var env = UseEnvironmentWithRequiredFields(); _Context.ReturnBytes("application/octet-stream", new byte[] { 5, 2, 1, 7 }); Assert.AreEqual("application/octet-stream", env.ResponseHeadersDictionary.ContentType); Assert.AreEqual(4, env.ResponseHeadersDictionary.ContentLength); Assertions.AreEqual(new byte[] { 5, 2, 1, 7 }, env.ResponseBodyBytes); }
public void ReturnBytes_Can_Send_Part_Of_Array() { var env = UseEnvironmentWithRequiredFields(); _Context.ReturnBytes("foo-foo", new byte[] { 5, 2, 1, 7 }, 1, 2); Assert.AreEqual("foo-foo", env.ResponseHeadersDictionary.ContentType); Assert.AreEqual(2, env.ResponseHeadersDictionary.ContentLength); Assertions.AreEqual(new byte[] { 2, 1 }, env.ResponseBodyBytes); }
public void ParseCommaSeparated_Parses_Lists_Of_Quality_Values_Correctly(string headerValue, string culture, string[] expectedQualityValues) { using (new CultureSwap(culture)) { var actual = QualityValue.ParseCommaSeparated(headerValue); Assertions.AreEqual( expectedQualityValues, actual.Select(r => r.ToString()).ToArray() ); } }
public void RequestBodyBytes_Resets_Stream_If_Seekable() { var env = UseEnvironmentWithRequiredFields(); var memoryStream = env.AddRequestBody(new byte[] { 1, 2, 3 }, new ContentTypeValue("text/plain")); memoryStream.Position = memoryStream.Length; var result = _Context.RequestBodyBytes(); Assertions.AreEqual(new byte[] { 1, 2, 3 }, result); }
public void TestReadingFile() { var reader = new GoogleTimelineKmlReader(); var positions = reader.Read(@"Gps\GoogleTimeline.kml"); Assertions.AreEqual(new List <Position>() { new Position(new DateTimeOffset(2016, 12, 18, 00, 46, 26, TimeSpan.Zero), 45.705188, -12.2042061), new Position(new DateTimeOffset(2016, 12, 18, 00, 47, 39, TimeSpan.Zero), 45.7053364, -12.20418839999999) }, positions.ToList()); }
public void RequestBodyBytes_Does_Not_Reset_Stream_If_Not_Seekable() { var env = UseEnvironmentWithRequiredFields(); using (var stream = new ForwardOnlyMemoryStream(new byte[] { 1, 2, 3 })) { env.Environment[EnvironmentKey.RequestBody] = stream; stream.MemoryStream.Position = stream.MemoryStream.Length; var result = _Context.RequestBodyBytes(); Assertions.AreEqual(new byte[0], result); } }
public void RequestBodyBytes_Refreshes_Cache_If_Stream_Changes() { var env = UseEnvironmentWithRequiredFields(); env.AddRequestBody(new byte[] { 1, 2, 3 }, new ContentTypeValue("text/plain")); var result1 = _Context.RequestBodyBytes(); env.AddRequestBody(new byte[] { 1, 2, 3 }, new ContentTypeValue("text/plain")); var result2 = _Context.RequestBodyBytes(); Assertions.AreEqual(result1, result2); Assert.AreNotSame(result1, result2); }
public void TestMethod1() { RunTest(() => { App.Reporter.TestDescription = "Functionality test of the Factorial Calculator page."; App.Reporter.TestStep = "Open the Factorial Calculator page."; App.FactorialPage.Open(); App.Reporter.TestStep = "Enter a number to calculate its factorial."; App.FactorialPage.CalculateFactorial(5); App.Reporter.TestStep = "Validate result of the factorial calculator."; Assertions.AreEqual(App.FactorialPage.ObtainResult(), "The factorial of 5 is: 120", "The validation is incorrect. Check the data."); }); }
public void ReturnJsonObject_FullControlVersion_Sets_Environment_Correctly(string input, string encodingName, string mimeType) { var encoding = DataRowParser.Encoding(encodingName); var expectedEncoding = encoding ?? Encoding.UTF8; var expectedMimeType = String.IsNullOrEmpty(mimeType) ? "application/json" : mimeType; var expectedText = input == null ? "null" : $"\"{input}\""; var expectedBody = expectedEncoding.GetBytes(expectedText); var expectedLength = expectedBody.Length.ToString(CultureInfo.InvariantCulture); _Responder.ReturnJsonObject(_Environment.Environment, input, null, encoding, mimeType); var contentType = _Environment.ResponseHeadersDictionary.ContentTypeValue; Assert.AreEqual(expectedMimeType, contentType.MediaType); Assert.AreEqual(expectedEncoding.WebName, contentType.Charset); Assert.AreEqual(expectedLength, _Environment.ResponseHeadersDictionary["Content-Length"]); Assertions.AreEqual(expectedBody, _Environment.ResponseBodyBytes); }
public void RequestBodyBytes_Returns_Content_Of_Stream(byte[] streamContent, int startPosition, byte[] expectedContent, int expectedPosition) { var env = UseEnvironmentWithRequiredFields(); using (var stream = new ForwardOnlyMemoryStream()) { if (streamContent != null) { stream.MemoryStream.Write(streamContent, 0, streamContent.Length); stream.MemoryStream.Position = startPosition; env.Environment[EnvironmentKey.RequestBody] = stream; } var actualContent = _Context.RequestBodyBytes(); var actualPosition = stream.Position; Assertions.AreEqual(expectedContent, actualContent); if (expectedPosition != -1) { Assert.AreEqual(expectedPosition, actualPosition); } } }
private void RestrictedHeaderAssignmentTest_CheckAction(string headerKey, string validValue, Action <IDictionary <string, string[]>, string, string[]> dictionaryAssign, Action <MockHttpListenerResponse> verifyResponseConfigured, bool caseSensitive = false) { foreach (var useUpperCase in new bool?[] { null, true, false }) { TestCleanup(); TestInitialise(); var headers = GetEnvironmentDictionary(); var caseAdjustedHeaderKey = headerKey; switch (useUpperCase) { case true: caseAdjustedHeaderKey = caseAdjustedHeaderKey.ToUpper(); break; case false: caseAdjustedHeaderKey = caseAdjustedHeaderKey.ToLower(); break; } dictionaryAssign(headers, caseAdjustedHeaderKey, new string[] { validValue }); // Check that the response has been set up correctly by the assignment... verifyResponseConfigured(_HttpListener.MockContext.MockResponse); // But the underlying response headers must not have been set, it will trigger an error Assert.IsNull(GetNativeHeaderValue(headerKey)); // Check that the environment headers dictionary shows the correct value as well Assertions.AreEqual(new string[] { validValue }, headers[headerKey]); Assert.AreEqual(1, headers.Count); Assert.AreEqual(true, headers.ContainsKey(headerKey)); Assert.AreEqual(true, headers.ContainsKey(caseAdjustedHeaderKey)); Assert.AreEqual(caseAdjustedHeaderKey, headers.Keys.Single()); Assertions.AreEqual(new string[] { validValue }, headers.Values.Single()); Assert.IsTrue(headers.TryGetValue(headerKey, out var tryGetResult)); Assertions.AreEqual(new string[] { validValue }, tryGetResult); } }
public void TestGetOptimizelyConfigService() { var datafileProjectConfig = DatafileProjectConfig.Create(TestData.TypedAudienceDatafile, new NoOpLogger(), new ErrorHandler.NoOpErrorHandler()); IDictionary <string, OptimizelyExperiment> experimentsMap = new Dictionary <string, OptimizelyExperiment> { { "feat_with_var_test", new OptimizelyExperiment( id: "11564051718", key: "feat_with_var_test", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "11617170975", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "x", new OptimizelyVariable( id: "11535264366", key: "x", type: "string", value: "xyz") } }) } } ) }, { "typed_audience_experiment", new OptimizelyExperiment( id: "1323241597", key: "typed_audience_experiment", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "A", new OptimizelyVariation( id: "1423767503", key: "A", featureEnabled: null, variablesMap: new Dictionary <string, OptimizelyVariable> ()) } } ) }, { "audience_combinations_experiment", new OptimizelyExperiment( id: "1323241598", key: "audience_combinations_experiment", audiences: "(\"exactString\" OR \"substringString\") AND (\"exists\" OR \"exactNumber\" OR \"gtNumber\" OR \"ltNumber\" OR \"exactBoolean\")", variationsMap: new Dictionary <string, OptimizelyVariation> { { "A", new OptimizelyVariation( id: "1423767504", key: "A", featureEnabled: null, variablesMap: new Dictionary <string, OptimizelyVariable> ()) } } ) }, { "feat2_with_var_test", new OptimizelyExperiment( id: "1323241599", key: "feat2_with_var_test", audiences: "(\"exactString\" OR \"substringString\") AND (\"exists\" OR \"exactNumber\" OR \"gtNumber\" OR \"ltNumber\" OR \"exactBoolean\")", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "1423767505", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "z", new OptimizelyVariable( id: "11535264367", key: "z", type: "integer", value: "150") } }) } } ) } }; var featuresMap = new Dictionary <string, OptimizelyFeature> { { "feat_no_vars", new OptimizelyFeature( id: "11477755619", key: "feat_no_vars", experimentRules: new List <OptimizelyExperiment>(), deliveryRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "11488548027", key: "feat_no_vars_rule", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "11557362669", new OptimizelyVariation( id: "11557362669", key: "11557362669", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable>()) } } ) }, experimentsMap: new Dictionary <string, OptimizelyExperiment>(), variablesMap: new Dictionary <string, OptimizelyVariable>()) }, { "feat_with_var", new OptimizelyFeature( id: "11567102051", key: "feat_with_var", experimentRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "11564051718", key: "feat_with_var_test", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "11617170975", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "x", new OptimizelyVariable( id: "11535264366", key: "x", type: "string", value: "xyz") } }) } } ) }, deliveryRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "11630490911", key: "feat_with_var_rule", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "11475708558", new OptimizelyVariation( id: "11475708558", key: "11475708558", featureEnabled: false, variablesMap: new Dictionary <string, OptimizelyVariable>() { { "x", new OptimizelyVariable("11535264366", "x", "string", "x") } }) } } ) }, experimentsMap: new Dictionary <string, OptimizelyExperiment> { { "feat_with_var_test", new OptimizelyExperiment( id: "11564051718", key: "feat_with_var_test", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "11617170975", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "x", new OptimizelyVariable( id: "11535264366", key: "x", type: "string", value: "xyz") } }) } } ) } }, variablesMap: new Dictionary <string, OptimizelyVariable> { { "x", new OptimizelyVariable(id: "11535264366", key: "x", type: "string", value: "x") } }) }, { "feat2", new OptimizelyFeature( id: "11567102052", key: "feat2", deliveryRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "11488548028", key: "11488548028", audiences: "(\"exactString\" OR \"substringString\") AND (\"exists\" OR \"exactNumber\" OR \"gtNumber\" OR \"ltNumber\" OR \"exactBoolean\")", variationsMap: new Dictionary <string, OptimizelyVariation> { { "11557362670", new OptimizelyVariation( id: "11557362670", key: "11557362670", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable>() ) } } ) }, experimentRules: new List <OptimizelyExperiment>(), experimentsMap: new Dictionary <string, OptimizelyExperiment>(), variablesMap: new Dictionary <string, OptimizelyVariable>()) }, { "feat2_with_var", new OptimizelyFeature( id: "11567102053", key: "feat2_with_var", deliveryRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "11630490912", key: "11630490912", audiences: "", variationsMap: new Dictionary <string, OptimizelyVariation> { { "11475708559", new OptimizelyVariation( id: "11475708559", key: "11475708559", featureEnabled: false, variablesMap: new Dictionary <string, OptimizelyVariable>() { { "z", new OptimizelyVariable( id: "11535264367", key: "z", type: "integer", value: "10") } }) } } ) }, experimentRules: new List <OptimizelyExperiment>() { new OptimizelyExperiment( id: "1323241599", key: "feat2_with_var_test", audiences: "(\"exactString\" OR \"substringString\") AND (\"exists\" OR \"exactNumber\" OR \"gtNumber\" OR \"ltNumber\" OR \"exactBoolean\")", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "1423767505", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "z", new OptimizelyVariable( id: "11535264367", key: "z", type: "integer", value: "150") } }) } } ) }, experimentsMap: new Dictionary <string, OptimizelyExperiment> { { "feat2_with_var_test", new OptimizelyExperiment( id: "1323241599", key: "feat2_with_var_test", audiences: "(\"exactString\" OR \"substringString\") AND (\"exists\" OR \"exactNumber\" OR \"gtNumber\" OR \"ltNumber\" OR \"exactBoolean\")", variationsMap: new Dictionary <string, OptimizelyVariation> { { "variation_2", new OptimizelyVariation( id: "1423767505", key: "variation_2", featureEnabled: true, variablesMap: new Dictionary <string, OptimizelyVariable> { { "z", new OptimizelyVariable( id: "11535264367", key: "z", type: "integer", value: "150") } }) } } ) } }, variablesMap: new Dictionary <string, OptimizelyVariable> { { "z", new OptimizelyVariable(id: "11535264367", key: "z", type: "integer", value: "10") } }) } }; OptimizelyConfig optimizelyConfig = new OptimizelyConfigService(datafileProjectConfig).GetOptimizelyConfig(); OptimizelyConfig expectedOptimizelyConfig = new OptimizelyConfig(datafileProjectConfig.Revision, datafileProjectConfig.SDKKey, datafileProjectConfig.EnvironmentKey, attributes: new OptimizelyAttribute[] { new OptimizelyAttribute { Id = "594015", Key = "house" }, new OptimizelyAttribute { Id = "594016", Key = "lasers" }, new OptimizelyAttribute { Id = "594017", Key = "should_do_it" }, new OptimizelyAttribute { Id = "594018", Key = "favorite_ice_cream" } }, audiences: new OptimizelyAudience[] { new OptimizelyAudience("0", "$$dummy", "{\"type\": \"custom_attribute\", \"name\": \"$opt_dummy_attribute\", \"value\": \"impossible_value\"}"), new OptimizelyAudience("3468206643", "exactBoolean", "[\"and\",[\"or\",[\"or\",{\"name\":\"should_do_it\",\"type\":\"custom_attribute\",\"match\":\"exact\",\"value\":true}]]]"), new OptimizelyAudience("3468206646", "exactNumber", "[\"and\",[\"or\",[\"or\",{\"name\":\"lasers\",\"type\":\"custom_attribute\",\"match\":\"exact\",\"value\":45.5}]]]"), new OptimizelyAudience("3468206642", "exactString", "[\"and\", [\"or\", [\"or\", {\"name\": \"house\", \"type\": \"custom_attribute\", \"value\": \"Gryffindor\"}]]]"), new OptimizelyAudience("3988293899", "exists", "[\"and\",[\"or\",[\"or\",{\"name\":\"favorite_ice_cream\",\"type\":\"custom_attribute\",\"match\":\"exists\"}]]]"), new OptimizelyAudience("3468206647", "gtNumber", "[\"and\",[\"or\",[\"or\",{\"name\":\"lasers\",\"type\":\"custom_attribute\",\"match\":\"gt\",\"value\":70}]]]"), new OptimizelyAudience("3468206644", "ltNumber", "[\"and\",[\"or\",[\"or\",{\"name\":\"lasers\",\"type\":\"custom_attribute\",\"match\":\"lt\",\"value\":1.0}]]]"), new OptimizelyAudience("3468206645", "notChrome", "[\"and\", [\"or\", [\"not\", [\"or\", {\"name\": \"browser_type\", \"type\": \"custom_attribute\", \"value\":\"Chrome\"}]]]]"), new OptimizelyAudience("3468206648", "notExist", "[\"not\",{\"name\":\"input_value\",\"type\":\"custom_attribute\",\"match\":\"exists\"}]"), new OptimizelyAudience("3988293898", "substringString", "[\"and\",[\"or\",[\"or\",{\"name\":\"house\",\"type\":\"custom_attribute\",\"match\":\"substring\",\"value\":\"Slytherin\"}]]]"), }, events: new OptimizelyEvent[] { new OptimizelyEvent() { Id = "594089", Key = "item_bought", ExperimentIds = new string[] { "11564051718", "1323241597" } }, new OptimizelyEvent() { Id = "594090", Key = "user_signed_up", ExperimentIds = new string[] { "1323241598", "1323241599" } } }, experimentsMap: experimentsMap, featuresMap: featuresMap, datafile: TestData.TypedAudienceDatafile); Assertions.AreEqual(expectedOptimizelyConfig, optimizelyConfig); }