public async Task NullCode__Throws_ArgumentNullException() { ResourceUpdateForm form = new ResourceUpdateForm("any", "any"); await Assert.ThrowsAsync <ArgumentNullException>(async() => { await _sut.Edit(null, form); }); }
public async Task UnexistingCode__404NotFound(string resourceCode) { ResourceUpdateForm form = new ResourceUpdateForm("any", "any"); var result = await _sut.Edit(resourceCode, form); Assert.NotNull(result); Assert.IsType <NotFoundResult>(result); }
public async Task Invalid_UpdateForm__Throws_ArgumentException(string newCategory, string newDescription) { ResourceUpdateForm form = new ResourceUpdateForm(newCategory, newDescription); ObjectResult result = await _sut.Edit(ResourceData.RESOURCE_01_CODE, form) as ObjectResult; Assert.NotNull(result); Assert.IsType <BadRequestObjectResult>(result); Assert.NotNull(result.Value); }
public async Task Success(string resourceCode, string newCategory, string newDescription) { // Arrange Resource expected = _resourceStore.Resources.FirstOrDefault(x => x.Code == resourceCode); expected.Category = newCategory; expected.Description = newDescription; // Act ResourceUpdateForm form = new ResourceUpdateForm(newCategory, newDescription); var result = _sut.Edit(resourceCode, form).Result.AsAcceptedAtActionResult(); //ObjectResult updatedResult = await _defaultSut.GetByCode(resourceCode) as ObjectResult; //Resource actual = updatedResult.Value as Resource; Resource actual = result.GetElement <Resource>(); // Assert Assert.Equal((int)HttpStatusCode.Accepted, result.StatusCode); Assert.Equal(expected, actual, _resourceComparer); }