public void TestPersistence() { // Test Persistence, UserflowForName // Intially, example1 = new Userflow("Purchase Crittercism SDK", 100000); Userflow example1 = ExampleUserflow(); string firstName = example1.Name(); int firstTimeout = example1.Timeout(); int firstValue = example1.Value(); // Test userflowForName Assert.IsTrue(Userflow.UserflowForName(firstName) == example1, "Expecting Userflow.UserflowForName(firstName)==example1"); Assert.IsTrue(Userflow.UserflowForName(firstName).Name() == firstName, "Expecting Userflow.UserflowForName(firstName).Name()==firstName"); // And example2 is example1's identical twin Userflow example2 = ExampleUserflow(); Trace.WriteLine("INITIALLY EQUAL"); //JsonConvert.SerializeObject(example1) Trace.WriteLine("example1 == " + example1); Trace.WriteLine("example2 == " + example2); // Change example1 example1.SetTimeout(example1.Timeout() + 100); example1.SetValue(example1.Value() + 10000); // Confirm members of example1 have been changed. Assert.IsFalse(example1.Timeout() == firstTimeout, "Not expecting example1.Timeout()==firstTimeout"); Assert.IsFalse(example1.Value() == firstValue, "Not expecting example1.Value()==firstValue"); Trace.WriteLine("NO LONGER EQUAL"); Trace.WriteLine("example1 == " + example1); Trace.WriteLine("example2 == " + example2); // Change example1 back example1.SetTimeout(firstTimeout); example1.SetValue(firstValue); Trace.WriteLine("SHOULD BE EQUAL AGAIN"); Trace.WriteLine("example1 == " + example1); Trace.WriteLine("example2 == " + example2); // Confirm members of example1 have been restored. Assert.IsTrue(example1.Name() == firstName, "Expecting example1.Name()==firstName"); Assert.IsTrue(example1.Timeout() == firstTimeout, "Expecting example1.Timeout()==firstTimeout"); Assert.IsTrue(example1.Value() == firstValue, "Expecting example1.Value()==firstValue"); }
public void TestValueProperty() { // Confirm value property is working. const int value1 = 1234; // $12.34 const int value2 = 9999; // $99.99 Userflow example = ExampleUserflow(); // Set and get the property value via dot syntax. example.SetValue(value1); Assert.IsTrue(example.Value() == value1, "Expecting example.Value() == {0}", value1); // Set and get the property value via getter and setter methods. example.SetValue(value2); Assert.IsTrue(example.Value() == value2, "Expecting example.Value() == {0}", value2); // Mixed syntax #1 example.SetValue(value1); Assert.IsTrue(example.Value() == value1, "Expecting example.Value() == {0}", value1); // Mixed syntax #2 example.SetValue(value2); Assert.IsTrue(example.Value() == value2, "Expecting example.Value() == {0}", value2); }