Пример #1
0
        public void IncorrectPostWithNullArray()
        {
            var mockSorter = new Mock <ISorter>();
            var controller = new NumbersController(mockSorter.Object);

            var result = controller.Post(null);

            Assert.Equal("Passed list is of wrong fromat", result);
        }
Пример #2
0
        public void IncorrectPostWithBadArrayFormat()
        {
            string list       = "5 5 4 1 9   100 2";
            var    mockSorter = new Mock <ISorter>();
            var    controller = new NumbersController(mockSorter.Object);
            var    result     = controller.Post(list);

            Assert.Equal("Passed list is of wrong fromat", result);
        }
Пример #3
0
        public void PostSortsAndSaves_ReturnTrue()
        {
            algorithmsMock.Setup(v => v.SimpleSort("4 3 2 1")).Returns("1 2 3 4");
            streamMock.Setup(v => v.CorrectInput("4 3 2 1")).Returns("");
            streamMock.Setup(v => v.SaveResult("4 3 2 1"));

            var result = controller.Post("4 3 2 1");

            Assert.AreEqual("data successfully sorted and saved", result);
        }
Пример #4
0
        public void CorrectPostWithGoodArray()
        {
            string path       = Path.Combine(rootPath, fileName);
            var    mockSorter = new Mock <ISorter>();
            var    controller = new NumbersController(mockSorter.Object);

            var result = controller.Post("1 8 1 20 1 5 100");

            Assert.Equal(String.Format("String accepted and sorted, file saved at {0}", path), result);
        }