public async Task Should_encrypt_the_password() { var user = new User { FirstName = "Test", LastName = "Test", Email = "*****@*****.**", Password = "******" }; var body = new MemoryStream(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(user))); _httpContextMock.Setup(c => c.Request.Body).Returns(body); await _passwordEncryptor.Invoke(_httpContextMock.Object); _nextMock.Verify(next => next(_httpContextMock.Object), Times.Once); _httpContextMock.VerifySet(c => c.Request.Body = It.IsAny <Stream>(), Times.Once); }