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); }
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); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
public async Task RemoveUser() { JsonWithResponse response = await _userController.RemoveUser(_user._Id); Assert.Equal("User removed!", response.Message); }
public async Task CreateUser() { JsonWithResponse response = await _userController.CreateUser(new CreateUser { DisplayName = "test-user" }); Assert.Equal("created", response.Message); }
public async Task RegenUserPasswordUser() { JsonWithResponse response = await _userController.RegenUserPassword(_user._Id); Assert.Equal("success", response.Message); }
public async Task GetKey_FetchKey() { JsonWithResponse response = await _keyController.GetKey("find-key"); Assert.Equal("success", response.Message); }
public async Task GetKey_MissingKey() { JsonWithResponse response = await _keyController.GetKey(""); Assert.Equal("Key value not supplied!", response.Message); }
public async Task GetKey_FetchMissingKey() { JsonWithResponse response = await _keyController.GetKey("key123"); Assert.Equal("Key not found!", response.Message); }
public async Task PopFromQueue_QueueDoesNotExist() { JsonWithResponse response = await _queueController.PopFromQueue("da-queue-2"); Assert.Equal("Queue not found or is empty!", response.Message); }
public async Task CreateKey_GoodModel() { JsonWithResponse response = await _keyController.CreateKey(new CreateValueItem { Key = "good-key", Value = "happy-day" }); Assert.Equal("created", response.Message); }