예제 #1
0
        public async Task Handle_InvalidUpdateUserByNameRequest_ReturnsError()
        {
            var request = new UpdateUserByNameRequest {
                Name = "NonUser", Data = new UserDto()
            };
            var response = await Mediator.HandleAsync(request);

            Assert.IsTrue(response.HasErrors);
        }
예제 #2
0
        public async Task Handle_UpdateUserByNameRequest_UpdatesUser()
        {
            var request = new UpdateUserByNameRequest
            {
                Name = _user.Name,
                Data = new UserDto {
                    Name = "NewName"
                }
            };

            var response = await Mediator.HandleAsync(request);

            Assert.IsFalse(response.HasErrors);
            var user = Context.Set <User>().FirstOrDefault();

            Assert.NotNull(user);
            Assert.AreEqual(_user.Id, user.Id);
            Assert.AreEqual("NewName", user.Name);
        }