Exemplo n.º 1
0
 public SkillsFactoryTests()
 {
     _provider = new Mock <IConversationStateProvider>();
     _context  = new Mock <ITurnContext>();
     //var brainState = new BrainState();
     //_provider.Setup(p => p.GetConversationState<BrainState>(_context.Object))
     //    .Returns(brainState);
     _factory = SkillFactory.GetInstance();
 }
Exemplo n.º 2
0
        public void GetInstanceTest()
        {
            // Arrange
            var factory = SkillFactory.GetInstance();

            // Act

            // Assert
            Assert.NotNull(factory);
        }
Exemplo n.º 3
0
        public void GetInstanceThroughFactoryTest()
        {
            // Arrange
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);
            var retorts = SkillFactory.GetInstance().GetSkill("retorts", _context.Object, _provider.Object);

            // Act

            // Assert
            Assert.NotNull(retorts);
        }
Exemplo n.º 4
0
        public void CountAfterInitTest(int expected)
        {
            // Arrange
            var factory    = SkillFactory.GetInstance();
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);

            // Act
            var actual = SkillFactory.Count;

            // Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 5
0
        public void GetSkillNonexistingTest()
        {
            // Arrange
            var factory    = SkillFactory.GetInstance();
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);

            // Act
            var skill = factory.GetSkill("greetings_like_you_test_it", _context.Object, _provider.Object);

            // Assert
            Assert.Null(skill);
        }
Exemplo n.º 6
0
        public void GetSkillExistingAgainTest()
        {
            // Arrange
            var factory    = SkillFactory.GetInstance();
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);

            // Act
            var skill  = factory.GetSkill("greetings", _context.Object, _provider.Object);
            var skill2 = factory.GetSkill("greetings", _context.Object, _provider.Object);

            // Assert
            Assert.Equal(skill, skill2);
        }
Exemplo n.º 7
0
        public void AboutTest()
        {
            // Arrange
            var expected   = "Contains set of quick responses from easily extendable file.";
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);
            var retorts = SkillFactory.GetInstance().GetSkill("retorts", _context.Object, _provider.Object);

            // Act
            var actual = retorts.About;

            // Assert
            Assert.NotNull(actual);
            Assert.NotEmpty(actual);
            Assert.Equal(expected, actual);
        }
Exemplo n.º 8
0
        public void ClearAfterInitSingleSkillTest(int expected)
        {
            // Arrange
            var factory    = SkillFactory.GetInstance();
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);

            // Act
            SkillFactory.Clear();
            var skill = factory.GetSkill("greetings", _context.Object, _provider.Object);

            SkillFactory.Clear();
            var actual = SkillFactory.Count;

            // Assert
            Assert.Equal(expected, actual);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        public void ProcessTest(string given)
        {
            // Arrange
            var factory    = SkillFactory.GetInstance(_context.Object, _provider.Object);
            var brainState = new BrainState();

            _provider.Setup(p => p.GetConversationState <BrainState>(_context.Object))
            .Returns(brainState);

            // Act
            var skill  = factory.GetSkill("greetings", _context.Object, _provider.Object);
            var actual = factory.Process(given);

            // Assert
            if (given != null && given.Equals("hi"))
            {
                Assert.NotNull(actual);
            }
            else
            {
                Assert.Null(actual);
            }
        }