예제 #1
0
        public async ValueTask <IActionResult> DebugMessage([FromQuery] string message, [FromServices] IMessageBus messageBus)
        {
            var msg = new WebTestMessage()
            {
                TestMessage = message
            };
            await messageBus.PublishAsync(msg);

            return(Json(new { message }));
        }
예제 #2
0
        public async ValueTask <IActionResult> Index(
            [FromServices] IRepository <WebEntity> repository,
            [FromServices] IRepository <WebEntity, int> repositoryWithKey,
            [FromServices] IAsyncRepository <WebEntity> asyncRepository,
            [FromServices] IAsyncRepository <WebEntity, int> asyncRepositoryWithKey,
            [FromServices] IMessageBus messageBus,
            [FromServices] IMessageConverter messageConverter)
        {
            var repositoryStatus       = "OK";
            var messageBusStatus       = "OK";
            var messageConverterStatus = "OK";

            try
            {
                var hashSet = new HashSet <DbContext>
                {
                    repository.GetDbContext(),
                    repositoryWithKey.GetDbContext(),
                    asyncRepository.GetDbContext(),
                    asyncRepositoryWithKey.GetDbContext()
                };
                hashSet.Single();
            }
            catch (Exception)
            {
                repositoryStatus = "Error";
            }
            try
            {
                var message    = new WebTestMessage();
                var descriptor = new RichMessageDescriptor("", nameof(WebTestMessage).ToLowerInvariant());
                await messageBus.OnMessageReceivedAsync(message, descriptor);
            }
            catch (Exception)
            {
                messageBusStatus = "Error";
            }
            var testMessage = new WebTestMessage
            {
                TestMessage = "debug"
            };
            var serializedMessageString = messageConverter.SerializeString(testMessage);

            if (serializedMessageString == "{}")
            {
                messageConverterStatus = "Error";
            }

            return(Json(new
            {
                RepositoryStatus = repositoryStatus,
                MessageBusStatus = messageBusStatus,
                MessageConverterStatus = messageConverterStatus,
            }));
        }
예제 #3
0
        public async ValueTask <IActionResult> Index(
            [FromServices] IRepository <WebEntity> repository,
            [FromServices] IRepository <WebEntity, int> repositoryWithKey,
            [FromServices] IAsyncRepository <WebEntity> asyncRepository,
            [FromServices] IAsyncRepository <WebEntity, int> asyncRepositoryWithKey,
            [FromServices] IMessageBus messageBus)
        {
            var repositoryStatus = "OK";
            var messageBusStatus = "OK";

            try
            {
                var hashSet = new HashSet <DbContext>
                {
                    repository.GetDbContext(),
                    repositoryWithKey.GetDbContext(),
                    asyncRepository.GetDbContext(),
                    asyncRepositoryWithKey.GetDbContext()
                };
                Debug.Assert(hashSet.Single() != null);
            }
            catch (Exception)
            {
                repositoryStatus = "Error";
            }
            try
            {
                var message    = new WebTestMessage();
                var descriptor = new RichMessageDescriptor("", nameof(WebTestMessage).ToLowerInvariant());
                await messageBus.OnMessageReceivedAsync(message, descriptor);
            }
            catch (Exception)
            {
                messageBusStatus = "Error";
            }
            return(Json(new
            {
                RepositoryStatus = repositoryStatus,
                MessageBusStatus = messageBusStatus
            }));
        }