public void Can_Convert_Test_With_Results() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); var testname = "Can_Convert_Test_With_Results"; var option1 = "one"; var option2 = "two"; var output = ABTester.Test(testname, option1, option2); Assert.IsTrue(output == option1 || output == option2); ABTester.Convert(testname); var results = ABTester.GetResults(testname); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count); Assert.IsTrue(results[0].Converted); } }
public void Can_Run_Two_Tests_And_Convert_One() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); var testname = "Can_Run_Two_Tests_And_Convert_One"; var option1 = "one"; var option2 = "two"; var output = ABTester.Test(testname, option1, option2); Assert.IsTrue(output == option1 || output == option2); //Call Start again to similate next request with new ABTester instance ABTester.Start(); var output2 = ABTester.Test(testname, option1, option2); Assert.IsTrue(output2 == option1 || output2 == option2); ABTester.Convert(testname); var results = ABTester.GetResults(testname); Assert.IsNotNull(results); Assert.AreEqual(2, results.Count); Assert.IsFalse(results[0].Converted); Assert.IsTrue(results[1].Converted); } }
public ActionResult ConvertTest3() { //Tell the ABTester this was the "downloaded" event ABTester.Convert("exampletest3"); return(RedirectToAction("Results")); }
public void Can_Get_Test_Results() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { var results = ABTester.GetResults("Can_Get_Test_Results"); Assert.IsNotNull(results); } }
public void Can_Start_Tester() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); } }
public void Can_Ouput_Test() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); var option1 = "one"; var option2 = "two"; var output = ABTester.Test("Can_Ouput_Test", option1, option2); Assert.IsTrue(output == option1 || output == option2); } }
public void Can_Ouput_Test_With_Five_Options() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); var option1 = "one"; var option2 = "two"; var option3 = "three"; var option4 = "four"; var option5 = "five"; var output = ABTester.Test("Can_Ouput_Test_With_Five_Options", option1, option2, option3, option4, option5); var options = new List <string> { option1, option2, option3, option4, option5 }; Assert.IsTrue(options.Contains(output)); } }
public void Can_Run_Test_And_Get_Active_Tests() { using (var req = MvcMockHelpers.SimulateRequest("http://localhost/Test.aspx")) { ABTester.Start(); Assert.IsNotNull(ABTester.Current); var testname = "Can_Run_Test_And_Get_Active_Tests"; var option1 = "one"; var option2 = "two"; var output = ABTester.Test(testname, option1, option2); Assert.IsTrue(output == option1 || output == option2); var results = ABTester.Settings.Storage.GetActiveTests(); Assert.IsNotNull(results); Assert.IsTrue(results.Count > 0); } }
private string showResults(List <string> extras) { var testName = extras.FirstOrDefault(); var results = ABTester.GetResults(testName); var sw = new StringWriter(); if (!results.Any()) { throw new ApplicationException(string.Format("Test: {0} not found", testName)); } var options = from r in results group r by r.Option into g select new { Option = g.Key, Total = g.Count(), Conversions = g.Count(or => or.Converted) }; var format = "{0,-18}{1,-12}{2,-12}{3,-12}"; sw.WriteLine(testName + " Results"); sw.WriteLine(); sw.WriteLine(format, "OPTION", "TOTAL", "CONVERT", "%"); foreach (var o in options) { var percentage = (double)o.Conversions / (double)o.Total; sw.WriteLine(format, o.Option, o.Total, o.Conversions, percentage.ToString("P")); } sw.WriteLine(format, "TOTAL:", options.Sum(o => o.Total), options.Sum(o => o.Conversions), ""); return(sw.ToString()); }
protected void Application_BeginRequest() { ABTester.Start(); }
// // GET: /Home/ public ActionResult Index() { ABTester.Start(); return(View()); }