Exemple #1
0
        public async Task PatchContactHttpTrigger_ReturnsStatusCodeOK_WhenRequestIsValid()
        {
            // Arrange
            _httpRequestMessageHelper.GetContactDetailsFromRequest <Models.ContactDetailsPatch>(_request).Returns(Task.FromResult(_contactDetailsPatch).Result);
            _resourceHelper.DoesCustomerExist(Arg.Any <Guid>()).ReturnsForAnyArgs(true);
            _provider.GetIdentityForCustomerAsync(Arg.Any <Guid>()).Returns(Task.FromResult <DigitalIdentity>(null));
            _provider.DoesContactDetailsWithEmailExistsForAnotherCustomer(Arg.Any <string>(), Arg.Any <Guid>()).Returns(Task.FromResult(false));
            _patchContactHttpTriggerService.GetContactDetailsForCustomerAsync(Arg.Any <Guid>(), Arg.Any <Guid>()).Returns(Task.FromResult(new ContactDetails()
            {
                CustomerId = new Guid(ValidCustomerId)
            }));
            _patchContactHttpTriggerService.UpdateAsync(Arg.Any <Models.ContactDetails>(), Arg.Any <Models.ContactDetailsPatch>()).Returns(Task.FromResult(_contactDetails).Result);

            // Act
            var result = await RunFunction(ValidCustomerId, ValidContactId);

            // Assert
            Assert.IsInstanceOf <HttpResponseMessage>(result);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }