コード例 #1
0
        public void HandleAsync_Should_Create_Customer_And_Publish_Event()
        {
            //arrange
            CreateCustomer command = new CreateCustomer(Guid.NewGuid(), "testing name", "*****@*****.**", "08139669123", "komp no 19");
            Customer       user    = new Customer(command.Id, command.FullName, command.Email, command.Phone, command.Address);

            _stubMongoRepository.Setup(x => x.AddAsync(It.IsAny <Customer>())).Verifiable();
            _stubBusPublisher.Setup(x => x.PublishAsync(It.IsAny <CustomerCreated>(), _stubContext.Object)).Verifiable();

            var mockCreateCustomerCommand = new CreateCustomerCommand(_stubMongoRepository.Object, _stubBusPublisher.Object);

            //act
            mockCreateCustomerCommand.HandleAsync(command, _stubContext.Object);
            //assert
            _stubMongoRepository.Verify();
            _stubBusPublisher.Verify();
        }