public async Task PatchContactHttpTrigger_ReturnsUnprocessableEntity_WhenEmptyPatchingEmailWithAnAssociatedDigitalEntity() { // Arange _httpRequestMessageHelper.Setup(x => x.GetDssTouchpointId(_request)).Returns("0000000001"); _httpRequestMessageHelper.Setup(x => x.GetDssApimUrl(_request)).Returns("http://localhost:7071/"); var patch = new Models.ContactDetailsPatch() { EmailAddress = "" }; _httpRequestMessageHelper.Setup(x => x.GetResourceFromRequest <Models.ContactDetailsPatch>(_request)).Returns(Task.FromResult(patch)); _resourceHelper.Setup(x => x.DoesCustomerExist(It.IsAny <Guid>())).Returns(Task.FromResult(true)); _patchContactHttpTriggerService.Setup(x => x.GetContactDetailsForCustomerAsync(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(Task.FromResult(new Models.ContactDetails() { CustomerId = new Guid(ValidCustomerId) })); _provider.Setup(x => x.GetIdentityForCustomerAsync(It.IsAny <Guid>())).Returns(Task.FromResult(new Models.DigitalIdentity() { CustomerId = new Guid(ValidCustomerId) })); _patchContactHttpTriggerService.Setup(x => x.UpdateAsync(It.IsAny <Models.ContactDetails>(), It.IsAny <Models.ContactDetailsPatch>())).Returns(Task.FromResult <Models.ContactDetails>(new Models.ContactDetails())); // Act var result = await RunFunction(ValidCustomerId, ValidContactId); // Assert Assert.IsInstanceOf <HttpResponseMessage>(result); Assert.AreEqual(422, (int)result.StatusCode); }
public void Setup() { _contactDetails = new Models.ContactDetails() { CustomerId = Guid.Parse(ValidCustomerId) }; _contactDetailsPatch = new Models.ContactDetailsPatch(); _request = new DefaultHttpRequest(new DefaultHttpContext()); _log = new Mock <ILogger>(); _resourceHelper = new Mock <IResourceHelper>(); _validate = new Validate(); _httpRequestMessageHelper = new Mock <IHttpRequestHelper>(); _patchContactHttpTriggerService = new Mock <IPatchContactDetailsHttpTriggerService>(); _provider = new Mock <IDocumentDBProvider>(); _httpResponseMessageHelper = new HttpResponseMessageHelper(); _function = new PatchContactHttpTrigger(_resourceHelper.Object, _httpRequestMessageHelper.Object, _validate, _patchContactHttpTriggerService.Object, _provider.Object, _httpResponseMessageHelper); }
public void Setup() { _contactDetails = Substitute.For <Models.ContactDetails>(); _contactDetailsPatch = Substitute.For <Models.ContactDetailsPatch>(); _request = new HttpRequestMessage() { Content = new StringContent(string.Empty), RequestUri = new Uri($"http://localhost:7071/api/Customers/7E467BDB-213F-407A-B86A-1954053D3C24/ContactDetails/1e1a555c-9633-4e12-ab28-09ed60d51cb3") }; _log = Substitute.For <ILogger>(); _resourceHelper = Substitute.For <IResourceHelper>(); _validate = Substitute.For <IValidate>(); _httpRequestMessageHelper = Substitute.For <IHttpRequestMessageHelper>(); _patchContactHttpTriggerService = Substitute.For <IPatchContactDetailsHttpTriggerService>(); _provider = Substitute.For <IDocumentDBProvider>(); _httpRequestMessageHelper.GetTouchpointId(_request).Returns("0000000001"); _httpRequestMessageHelper.GetApimURL(_request).Returns("http://localhost:7071/"); }