Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public async void GivenLoadOptions_ControllerReturnsLoadResult()
        {
            // Arrange
            var loadOptions = new DataSourceLoadOptionsBase();
            var words       = Helper.FakeEnumerable(() => new Word().Fake()).ToList();
            var loadResult  = new LoadResult
            {
                data = words
            };

            // Act
            _wordManager.Setup(m => m.DataSourceLoadAsync(loadOptions))
            .ReturnsAsync(loadResult)
            .Verifiable();

            var result = await _wordsController.GetWords(loadOptions).ConfigureAwait(false);

            // Assert
            _wordManager.Verify(m => m.DataSourceLoadAsync(loadOptions), Times.Once);
            Assert.Equal(typeof(ActionResult <LoadResponse <WordModel> >), result.GetType());
        }