コード例 #1
0
        public async Task UpdateUserProfile_ThrowsNotFoundExceptionk_WhenUserNotFound()
        {
            //Arrange
            Mock <IApplicationUsersRepository> applicationRepository = new Mock <IApplicationUsersRepository>();
            Mock <IApplicationUsersUnitOfWork> unitOfWork            = new Mock <IApplicationUsersUnitOfWork>();

            applicationRepository.Setup(r => r.UpdateProfile(It.IsAny <Guid>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>())).Throws <NotFoundException>();
            unitOfWork.Setup(u => u.ApplicationUsers).Returns(applicationRepository.Object);
            var handler = new UserInfoUpdateHandler(unitOfWork.Object);

            //Act/Assert
            await Assert.ThrowsAsync <NotFoundException>(async() =>
            {
                await handler.HandleAsync(new UpdateUserInfoCommand(
                                              id: Guid.NewGuid(),
                                              firstName: String.Empty,
                                              lastName: String.Empty,
                                              education: String.Empty,
                                              occupation: String.Empty,
                                              dateOfBirth: DateTime.Now
                                              ));
            });
        }
コード例 #2
0
        public async Task UpdateUserProfile_ReturnsTask_WhenProfileUpdated()
        {
            //Arrange
            Mock <IApplicationUsersRepository> applicationRepository = new Mock <IApplicationUsersRepository>();
            Mock <IApplicationUsersUnitOfWork> unitOfWork            = new Mock <IApplicationUsersUnitOfWork>();

            applicationRepository.Setup(r => r.UpdateProfile(It.IsAny <Guid>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>(), It.IsAny <String>())).Returns(Task.CompletedTask);
            unitOfWork.Setup(u => u.ApplicationUsers).Returns(applicationRepository.Object);

            var handler = new UserInfoUpdateHandler(unitOfWork.Object);

            //Act
            await handler.HandleAsync(new UpdateUserInfoCommand(
                                          id : Guid.NewGuid(),
                                          firstName : String.Empty,
                                          lastName : String.Empty,
                                          education : String.Empty,
                                          occupation : String.Empty,
                                          dateOfBirth : DateTime.Now
                                          ));

            //Assert
        }