public AddUserControler(ILibraryPresenter libraryPresenter)
 {
     InitializeComponent();
     _libraryPresenter = libraryPresenter;
     presenter         = new AddUserPresenter(_libraryPresenter);
     Initialize();
 }
Beispiel #2
0
 public static string WMSName = "佳贝斯-WMS立库管理系统";//系统名称配置
 public LoginView()
 {
     InitializeComponent();
     this.presenter = new AddUserPresenter(this);
     DatabaseCfg();
     InitTabbedMDI();
     this.lc_WMSName.Text = WMSName;
 }
Beispiel #3
0
        public void Contains_Ok_Status_Code_When_Use_Case_Succeeds()
        {
            // arrange
            var presenter = new AddUserPresenter();

            // act
            presenter.Handle(new AddUserResponse(1, true));

            // assert
            Assert.Equal((int)HttpStatusCode.OK, presenter.ContentResult.StatusCode);
        }
Beispiel #4
0
        public void Contains_Errors_When_Use_Case_Fails()
        {
            // arrange
            var presenter = new AddUserPresenter();

            // act
            presenter.Handle(new AddUserResponse(new [] { "Missing first name" }));

            // assert
            dynamic data = JsonConvert.DeserializeObject(presenter.ContentResult.Content);

            Assert.False(data.success.Value);
            Assert.Equal("missing first name", data.errors.First.Value);
        }
Beispiel #5
0
        public void Contains_Id_When_Use_Case_Succeeds()
        {
            // arrange
            var presenter = new AddUserPresenter();

            // act
            presenter.Handle(new AddUserResponse(2, true));

            // assert
            dynamic data = JsonConvert.DeserializeObject(presenter.ContentResult.Content);

            Assert.True(data.success.Value);
            Assert.Equal("2", data.id.Value);
        }
Beispiel #6
0
 public UserController(IAddAsyncUserUseCase addUserUseCase, AddUserPresenter addUserPresenter,
                       IGetAsyncUserByIdUseCase getUserByIdUseCase, GetUserByIdPresenter getUserByIdPresenter,
                       IGetAsyncUsersUseCase getUsersUseCase, GetUsersPresenter getUsersPresenter,
                       IUpdateAsyncUserByIdUseCase updateUserUseCase, UpdateUserByIdPresenter updateUserPresenter,
                       IDeleteAsyncUserByIdUseCase deleteUserByIdUseCase, DeleteUserByIdPresenter deleteUserByIdPresenter)
 {
     _addAsyncUserUseCase        = addUserUseCase;
     _addUserPresenter           = addUserPresenter;
     _getAsyncUserByIdUseCase    = getUserByIdUseCase;
     _getUserByIdPresenter       = getUserByIdPresenter;
     _getAsyncUsersUseCase       = getUsersUseCase;
     _getUsersPresenter          = getUsersPresenter;
     _updateAsyncUserUseCase     = updateUserUseCase;
     _updateUserPresenter        = updateUserPresenter;
     _deleteAsyncUserByIdUseCase = deleteUserByIdUseCase;
     _deleteUserByIdPresenter    = deleteUserByIdPresenter;
 }
Beispiel #7
0
        public async void Post_Returns_Ok_When_Update_User_By_Id_Use_Case_Succeeds()
        {
            // arrange
            var mockUserRepository = new Mock <IUserRepository>();

            mockUserRepository
            .Setup(repo => repo.Update("", It.IsAny <User>()))
            .Returns(Task.FromResult(new Core.Dto.GatewayResponses.Repositories.UpdateUserByIdResponse(1, true)));

            // fakes
            var outputAddUserPort        = new AddUserPresenter();
            var outputGetUsersPort       = new GetUsersPresenter();
            var outputGetUserByIdPort    = new GetUserByIdPresenter();
            var outputUpdateUserPort     = new UpdateUserByIdPresenter();
            var outputDeleteUserByIdPort = new DeleteUserByIdPresenter();

            var addUserUseCase        = new AddAsyncUserUseCase(mockUserRepository.Object);
            var getUsersUseCase       = new GetAsyncUsersUseCase(mockUserRepository.Object);
            var getUserByIdUseCase    = new GetAsyncUserByIdUseCase(mockUserRepository.Object);
            var updateUserByIdUseCase = new UpdateAsyncUserByIdUseCase(mockUserRepository.Object);
            var deleteUserByIdUseCase = new DeleteAsyncUserByIdUseCase(mockUserRepository.Object);

            var controller = new UserController(addUserUseCase, outputAddUserPort,
                                                getUserByIdUseCase, outputGetUserByIdPort,
                                                getUsersUseCase, outputGetUsersPort,
                                                updateUserByIdUseCase, outputUpdateUserPort,
                                                deleteUserByIdUseCase, outputDeleteUserByIdPort);

            // act
            var result = await controller.UpdateUserByIdAsync("userIdToUpdate", new UpdateUserRequest()
            {
                Updated_id = 999, Updated_name = "newName", Updated_birthdate = DateTime.Now, Updated_password = "******"
            });

            // assert
            var statusCode = ((ContentResult)result).StatusCode;

            Assert.True(statusCode.HasValue && statusCode.Value == (int)HttpStatusCode.OK);
        }
Beispiel #8
0
        public async void Post_Returns_Ok_When_Add_User_Use_Case_Succeeds()
        {
            // arrange
            var mockUserRepository = new Mock <IUserRepository>();

            mockUserRepository
            .Setup(repo => repo.Create(It.IsAny <User>(), It.IsAny <string>()))
            .Returns(Task.FromResult(new CreateUserResponse(1, true)));

            // fakes
            var outputAddUserPort        = new AddUserPresenter();
            var outputGetUsersPort       = new GetUsersPresenter();
            var outputGetUserByIdPort    = new GetUserByIdPresenter();
            var outputUpdateUserPort     = new UpdateUserByIdPresenter();
            var outputDeleteUserByIdPort = new DeleteUserByIdPresenter();

            var addUserUseCase        = new AddAsyncUserUseCase(mockUserRepository.Object);
            var getUsersUseCase       = new GetAsyncUsersUseCase(mockUserRepository.Object);
            var getUserByIdUseCase    = new GetAsyncUserByIdUseCase(mockUserRepository.Object);
            var updateUserByIdUseCase = new UpdateAsyncUserByIdUseCase(mockUserRepository.Object);
            var deleteUserByIdUseCase = new DeleteAsyncUserByIdUseCase(mockUserRepository.Object);

            var controller = new UserController(addUserUseCase, outputAddUserPort,
                                                getUserByIdUseCase, outputGetUserByIdPort,
                                                getUsersUseCase, outputGetUsersPort,
                                                updateUserByIdUseCase, outputUpdateUserPort,
                                                deleteUserByIdUseCase, outputDeleteUserByIdPort);

            // act
            var result = await controller.AddUserAsync(new Models.Request.AddUserRequest());

            // assert
            var statusCode = ((ContentResult)result).StatusCode;

            Assert.True(statusCode.HasValue && statusCode.Value == (int)HttpStatusCode.OK);
        }
Beispiel #9
0
 public AddUserPage()
 {
     InitializeComponent();
     _presenter = new AddUserPresenter(this);
 }