public void ValidChoiceForParameterIsItsOwnCanonicalValueTest() { ITemplateParameter param = new MockParameter() { Name = "TestName", Choices = new Dictionary <string, string>() { { "foo", "Foo value" }, { "bar", "Bar value" } } }; IReadOnlyList <ITemplateParameter> parametersForTemplate = new List <ITemplateParameter>() { param }; ITemplateInfo template = new MockTemplate() { Parameters = parametersForTemplate }; string canonical = TelemetryHelper.GetCanonicalValueForChoiceParamOrDefault(template, "TestName", "foo"); Assert.Equal("foo", canonical); }
public void ChoiceValueCaseDifferencesContributeToAmbiguousMatchTest() { ITemplateParameter param = new MockParameter() { Name = "TestName", Choices = new Dictionary <string, string>() { { "foot", "Foo value" }, { "bar", "Bar value" }, { "Football", "Foo value" }, { "FOOTPOUND", "Foo value" } } }; IReadOnlyList <ITemplateParameter> parametersForTemplate = new List <ITemplateParameter>() { param }; ITemplateInfo template = new MockTemplate() { Parameters = parametersForTemplate }; string canonical = TelemetryHelper.GetCanonicalValueForChoiceParamOrDefault(template, "TestName", "foo"); Assert.Null(canonical); }
public void AmbiguousStartsWithValueHasNullCanonicalValueTest() { ITemplateParameter param = new MockParameter() { Name = "TestName", Choices = new Dictionary <string, string>() { { "foo", "Foo value" }, { "bar", "Bar value" }, { "foot", "Foot value" } } }; IReadOnlyList <ITemplateParameter> parametersForTemplate = new List <ITemplateParameter>() { param }; ITemplateInfo template = new MockTemplate() { Parameters = parametersForTemplate }; string canonical = TelemetryHelper.GetCanonicalValueForChoiceParamOrDefault(template, "TestName", "f"); Assert.Null(canonical); }
public void TestTemplateAsParentObject() { this.OnLoadCalled = false; this.OnUnloadCalled = false; AimlBot.Request r = new AimlBot.Request(); MockTemplate mt = new MockTemplate(); mt.OnLoad += new EventHandler <EventArgs>(mt_OnLoad); mt.OnUnload += new EventHandler <EventArgs>(mt_OnUnload); // lets run through the whole life cycle mt.Init("Hello, $NAME$!"); mt.Load(r); Assert.AreEqual(true, this.OnLoadCalled); Assert.AreEqual("World", mt.Name); Assert.AreEqual("Hello, World!", mt.Render()); mt.Unload(); Assert.AreEqual(true, this.OnUnloadCalled); Assert.AreEqual(string.Empty, mt.Name); }
public void UnknownParameterNameHasNullCanonicalValueTest() { ITemplateParameter param = new MockParameter() { Name = "TestName", Choices = null }; IReadOnlyList <ITemplateParameter> parametersForTemplate = new List <ITemplateParameter>() { param }; ITemplateInfo template = new MockTemplate() { Parameters = parametersForTemplate }; string canonical = TelemetryHelper.GetCanonicalValueForChoiceParamOrDefault(template, "OtherName", "whatever"); Assert.Null(canonical); }
public void TestTemplateAsParentObject() { this.OnLoadCalled = false; this.OnUnloadCalled = false; AimlBot.Request r = new AimlBot.Request(); MockTemplate mt = new MockTemplate(); mt.OnLoad += new EventHandler<EventArgs>(mt_OnLoad); mt.OnUnload += new EventHandler<EventArgs>(mt_OnUnload); // lets run through the whole life cycle mt.Init("Hello, $NAME$!"); mt.Load(r); Assert.AreEqual(true, this.OnLoadCalled); Assert.AreEqual("World", mt.Name); Assert.AreEqual("Hello, World!", mt.Render()); mt.Unload(); Assert.AreEqual(true, this.OnUnloadCalled); Assert.AreEqual(string.Empty, mt.Name); }