Example #1
0
        public async Task SearchKey_MissingKey()
        {
            JsonWithResponse response = await _keyController.SearchKey(new KeySearch { SearchTerm = "not-a-key", IncludeValues = false });

            Dictionary <string, string> parsedResponse = response.Response as Dictionary <string, string>;

            Assert.Empty(parsedResponse);
        }
Example #2
0
        public async Task SearchKey_KeyAndValue()
        {
            JsonWithResponse response = await _keyController.SearchKey(new KeySearch { SearchTerm = "t*y", IncludeValues = true });

            Dictionary <string, string> parsedResponse = response.Response as Dictionary <string, string>;

            string valRes = parsedResponse.SingleOrDefault(x => x.Key == "toy").Value;

            Assert.Equal("a magic toy", valRes);
        }
Example #3
0
        public async Task PopFromQueue()
        {
            JsonWithResponse response = await _queueController.PopFromQueue("da-queue");

            Assert.Equal("success", response.Message);

            QueueMessage resActual = response.Response as QueueMessage;

            Assert.Equal("da-queue", resActual.QueueName);
            Assert.Equal("a pop message", resActual.Message);
        }
Example #4
0
        public async Task DeleteFromQueue()
        {
            JsonWithResponse response = await _queueController.DeleteFromQueue("da-queue");

            Assert.Equal("deleted", response.Message);

            QueueMessage resActual = response.Response as QueueMessage;

            Assert.Equal("da-queue", resActual.QueueName);
            Assert.Equal("a delete message", resActual.Message);
        }
Example #5
0
        public async Task RegenUserPassword_MissingUser()
        {
            Guid             noGuid   = Guid.NewGuid();
            JsonWithResponse response = await _userController.RegenUserPassword(noGuid);

            Assert.Equal("Not found", response.Message);

            JsonError errorResponse = response as JsonError;

            Assert.Equal($"{noGuid} was not found!", errorResponse.Errors.Single());
        }
Example #6
0
        public async Task SearchKey_KeyOnly()
        {
            JsonWithResponse response = await _keyController.SearchKey(new KeySearch { SearchTerm = "t*y", IncludeValues = false });

            Dictionary <string, string> parsedResponse = response.Response as Dictionary <string, string>;

            var value = parsedResponse.First();

            Assert.Equal("toy", value.Key);
            Assert.Empty(value.Value);
        }
Example #7
0
        public async Task PushToQueue()
        {
            QueueMessagesPost post = new QueueMessagesPost {
                QueueName = "da-queue", Messages = new List <string> {
                    "test"
                }
            };

            JsonWithResponse response = await _queueController.PushToQueue(post);

            Assert.Equal($"Added {post.Messages.Count} to queue: {post.QueueName}", response.Message);
        }
Example #8
0
        public async Task CreateUser_BadModel()
        {
            // bad model test setup
            var controller = new UserController(_mockService.Object);

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

            JsonWithResponse response = await controller.CreateUser(new CreateUser { });

            Assert.Equal("Invalid user request!", response.Message);
        }
Example #9
0
        public async Task PushToQueue_BadModel()
        {
            // test setup
            var controller = new QueueController(_mockService.Object);

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

            // mock request
            JsonWithResponse response = await controller.PushToQueue(new QueueMessagesPost { QueueName = "da-queue" });

            Assert.Equal("Invalid queue request!", response.Message);
        }
Example #10
0
        public async Task SearchKey_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.SearchKey(null);

            Assert.Equal("Invalid key search request!", response.Message);
        }
Example #11
0
        public async Task RemoveUser()
        {
            JsonWithResponse response = await _userController.RemoveUser(_user._Id);

            Assert.Equal("User removed!", response.Message);
        }
Example #12
0
        public async Task CreateUser()
        {
            JsonWithResponse response = await _userController.CreateUser(new CreateUser { DisplayName = "test-user" });

            Assert.Equal("created", response.Message);
        }
Example #13
0
        public async Task RegenUserPasswordUser()
        {
            JsonWithResponse response = await _userController.RegenUserPassword(_user._Id);

            Assert.Equal("success", response.Message);
        }
Example #14
0
        public async Task GetKey_FetchKey()
        {
            JsonWithResponse response = await _keyController.GetKey("find-key");

            Assert.Equal("success", response.Message);
        }
Example #15
0
        public async Task GetKey_MissingKey()
        {
            JsonWithResponse response = await _keyController.GetKey("");

            Assert.Equal("Key value not supplied!", response.Message);
        }
Example #16
0
        public async Task GetKey_FetchMissingKey()
        {
            JsonWithResponse response = await _keyController.GetKey("key123");

            Assert.Equal("Key not found!", response.Message);
        }
Example #17
0
        public async Task PopFromQueue_QueueDoesNotExist()
        {
            JsonWithResponse response = await _queueController.PopFromQueue("da-queue-2");

            Assert.Equal("Queue not found or is empty!", response.Message);
        }
Example #18
0
        public async Task CreateKey_GoodModel()
        {
            JsonWithResponse response = await _keyController.CreateKey(new CreateValueItem { Key = "good-key", Value = "happy-day" });

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