Пример #1
0
        public async Task TranslatorController_return_stream()
        {
            _translationServiceMock.Setup <TranslationResponse>(m => m.Tanslate(It.IsAny <TranslationParameters>())).Returns(new TranslationResponse("succes"));

            IActionResult result = await _translatorController.Get(new TranslationParameters(), "text/plain");

            Assert.True(result.GetType() == typeof(FileStreamResult));
        }
        public void TestEmptyModel()
        {
            var controller = new TranslatorController(_mapper);
            var request    = new TranslationRequest();
            var response   = controller.Get(request);

            Assert.AreEqual(System.Net.HttpStatusCode.NotFound, response.Code);
        }
        public void TestCaseInsensitive()
        {
            var controller = new TranslatorController(_mapper);
            var request    = new TranslationRequest
            {
                Language = "eN",
                Text     = "HeLlO, WoRlD!"
            };
            var response = controller.Get(request);

            Assert.AreEqual(System.Net.HttpStatusCode.OK, response.Code);
            Assert.AreEqual("привет мир", response.Translation);
        }
        public void TestCorrectTranslation()
        {
            var controller = new TranslatorController(_mapper);
            var request    = new TranslationRequest
            {
                Language = "En",
                Text     = "Hello, world!"
            };
            var response = controller.Get(request);

            Assert.AreEqual(System.Net.HttpStatusCode.OK, response.Code);
            Assert.AreEqual("привет мир", response.Translation);
        }