static void Main(string[] args)
        {
            CustomerRepository    repository = new CustomerRepository();
            CreateCustomerUseCase useCase    = new CreateCustomerUseCase(repository);

            useCase.Execute("id", "name");
        }
예제 #2
0
        public void CreateCustomerAction(Request request)
        {
            CreateCustomerRequest createRequest = new CreateCustomerRequest(
                request.Get("id"),
                request.Get("name")
                );

            customerUseCase.Execute(createRequest);
        }
예제 #3
0
        public void ItShouldReturnTrueIfUseCaseExecutedIsValid()
        {
            var mockRepository = new Mock <CustomerRepository>();
            var mockConverter  = new Mock <CustomerConverter>();

            var createCustomerUseCase = new CreateCustomerUseCase(mockRepository.Object, mockConverter.Object);

            CustomerId   id       = new CustomerId("1111");
            CustomerName name     = new CustomerName("customer");
            Customer     customer = Customer.SignUp(id, name);

            CreateCustomerRequest request = new CreateCustomerRequest(id.Id(), name.Name());

            var actual = createCustomerUseCase.Execute(request);

            Assert.AreEqual("1111", actual.Id);
            Assert.AreEqual("customer", actual.Name);
        }
예제 #4
0
        public void ItShoulReturnTrueWhenCustomerIsTryingToSave()
        {
            //Arrange
            var mockRepository  = new Mock <ICustomerRepository>();
            var converter       = new CustomerConverter();
            var customerUseCase = new CreateCustomerUseCase(mockRepository.Object, converter);

            CustomerId   customerId   = new CustomerId(1234);
            CustomerName customerName = new CustomerName("customer");
            Customer     customer     = Customer.Create(customerId, customerName);

            mockRepository.Setup(s => s.Save(customer)).Returns(true);

            //Act
            CreateCustomerRequest request = new CreateCustomerRequest(1, "Name");
            var result = customerUseCase.Execute(request);

            //Assert
            Assert.AreEqual(result, true);
        }
        public CustomerDTO CustomerAction(Request request)
        {
            CreateCustomerRequest requestCustomer = new CreateCustomerRequest(request.Get("id"), request.Get("name"));

            return(_customerUseCase.Execute(requestCustomer));
        }