public void AddTest(string line, bool expected, bool existsBefore) { // Arrange var retorts = new Retorts("test"); retorts.Clear(); var question = (!string.IsNullOrWhiteSpace(line)) ? line.Split("|")[1] : ""; var answer = "defaultAnswer1"; if (existsBefore) { Assert.True(retorts.Add(question, answer)); } // Act var result = retorts.Add(line); // Assert Assert.Equal(expected, result); }
public void ClearTest() { // Arrange var retorts = new Retorts("test"); var question = "question1_test"; var answer = "defaultAnswer1_test"; retorts.Add(question.Trim(), answer); Assert.True(retorts.Count() > 0); var expectedSize = 0; // Act retorts.Clear(); var actualSize = retorts.Count(); // Assert Assert.Equal(expectedSize, actualSize); }
public void ContainsTest(string question, bool expected, bool existsBefore) { // Arrange var retorts = new Retorts("test"); retorts.Clear(); var answer = "defaultAnswer1"; if (existsBefore) { retorts.Add(question.Trim(), answer); } // Act var result = retorts.Contains(question); // Assert Assert.Equal(expected, result); }
public void ProcessTest(string request, string expected) { // Arrange var brainState = new BrainState(); _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object)) .Returns(brainState); var skills = SkillFactory.GetInstance(_context.Object, _provider.Object); Retorts retorts = Retorts.Instance(_context.Object, _provider.Object); // TODO add call to load retorts from file var resultOfAdd = retorts.Add("hi", "hello"); // Act var actual = retorts.Process(request); bool removal = retorts.Remove("hi"); // Assert Assert.Equal(expected, actual); }
public void CountTest(bool mustHaveEntries) { // Arrange var retorts = new Retorts("test"); retorts.Clear(); var expectedSize = 0; if (mustHaveEntries) { var question = "question1_test"; var answer = "defaultAnswer1_test"; Assert.True(retorts.Add(question.Trim(), answer)); expectedSize = 1; } // Act var actualSize = retorts.Count(); // Assert Assert.Equal(expectedSize, actualSize); }