Пример #1
0
        public async Task CreateKey_BadModel()
        {
            // test setup
            var controller = new KeyController(_mockService.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = new DefaultHttpContext()
                {
                    User = _claimsPrinciple
                }
            };
            controller.ModelState.AddModelError("fakeError", "fakeError");

            // mock request
            JsonWithResponse response = await controller.CreateKey(new CreateValueItem { Key = "yo" });

            Assert.Equal("Invalid key request!", response.Message);
        }
Пример #2
0
        public async Task CreateKey_GoodModel()
        {
            JsonWithResponse response = await _keyController.CreateKey(new CreateValueItem { Key = "good-key", Value = "happy-day" });

            Assert.Equal("created", response.Message);
        }