コード例 #1
0
        public void PostCallsCollectWords()
        {
            // arrange
            var collector = new Mock <ICollect>();
            var store     = new Mock <IStorage>();
            var sut       = new WordsController(collector.Object, store.Object);

            // act
            sut.Post(new FormData());

            // assert
            collector.Verify(x => x.CollectWords(It.IsAny <string>()), Times.Once);
        }
コード例 #2
0
        public void PosttWords_ShouldAddWords()
        {
            // Arrange
            WordsController wc = new WordsController();

            //Act
            string[] saPost = new string[] { "dog", "cat", "horse", "elephant" };
            Dictionary <int, string> resultPost = wc.Post(saPost);

            // Assert
            Dictionary <int, string> resExpected = new Dictionary <int, string> {
                { 0, "dog" }, { 1, "cat" }, { 2, "horse" }, { 3, "elephant" }
            };

            CollectionAssert.AreEquivalent(resultPost, resExpected);
        }
コード例 #3
0
        public void GetWords_ShouldReturnWordsSortedByValueDescendingNotUnique()
        {
            // Arrange
            WordsController wc = new WordsController();

            //Act
            string[] saPost = new string[] { "dog", "cat", "horse", "elephant" };
            Dictionary <int, string> resultPost     = wc.Post(saPost);
            Dictionary <int, string> resultGetWords = wc.GetWords("-value", false);

            // Assert
            Dictionary <int, string> resExpected = new Dictionary <int, string> {
                { 2, "horse" }, { 3, "elephant" }, { 0, "dog" }, { 1, "cat" }
            };

            CollectionAssert.AreEquivalent(resultGetWords, resExpected);
        }