private void Given_a_service_collection_with_a_imMemoryDb()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();

            _serviceProvider = serviceProviderBuilder
                               .WithServicesFromStartup()
                               .WithInMemoryDb()
                               .OverwriteService(typeof(IRestClient), new StubKafkaRestClient())
                               .Build();
        }
        private void Given_a_service_collection_with_a_imMemoryDb()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();

            _serviceProvider = serviceProviderBuilder
                               .WithServicesFromStartup()
                               .WithInMemoryDb()
                               .Build();

            _capabilityApplicationService = _serviceProvider.GetService <ICapabilityApplicationService>();
        }
Пример #3
0
        private void Given_a_service_collection_with_a_imMemoryDb_and_SlackFacadeSpy()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();

            serviceProviderBuilder = serviceProviderBuilder
                                     .WithServicesFromStartup()
                                     .WithInMemoryDb()
                                     .RemoveType(typeof(ISlackFacade));

            var slackFacadeSpy = new SlackFacadeSpy();

            serviceProviderBuilder.Services.AddSingleton <ISlackFacade>(slackFacadeSpy);


            _serviceProvider = serviceProviderBuilder.Build();
        }
Пример #4
0
        public async Task get_all_clusters_returns_expected_status_code()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();
            var serviceProvider        = serviceProviderBuilder
                                         .WithServicesFromStartup()
                                         .WithInMemoryDb()
                                         .OverwriteService(typeof(IRestClient), new StubKafkaRestClient())
                                         .Build();
            var clusterController = new ClusterController(serviceProvider.GetService <IClusterRepository>());

            var response = await clusterController.GetAll();

            var okResult = response as ObjectResult;

            Assert.Equal(HttpStatusCode.OK.GetHashCode(), okResult.StatusCode);
        }
Пример #5
0
        public async Task get_all_clusters_returns_expected_body_when_no_clusters_available()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();
            var serviceProvider        = serviceProviderBuilder
                                         .WithServicesFromStartup()
                                         .WithInMemoryDb()
                                         .OverwriteService(typeof(IRestClient), new StubKafkaRestClient())
                                         .Build();
            var clusterController = new ClusterController(serviceProvider.GetService <IClusterRepository>());

            var response = await clusterController.GetAll();

            var okResult = response as OkObjectResult;

            Assert.Equal(
                expected: "[]",
                actual: JsonSerializer.Serialize(okResult.Value)
                );
        }
Пример #6
0
        public async Task get_all_clusters_returns_expected_body_with_clusters_available()
        {
            var serviceProviderBuilder = new ServiceProviderBuilder();
            var serviceProvider        = serviceProviderBuilder
                                         .WithServicesFromStartup()
                                         .WithInMemoryDb()
                                         .OverwriteService(typeof(IRestClient), new StubKafkaRestClient())
                                         .Build();
            var clusterController = new ClusterController(serviceProvider.GetService <IClusterRepository>());

            var clusterRepository = serviceProvider.GetService <IClusterRepository>();
            await clusterRepository.AddAsync("Dummy test cluster #1", "lkc-9999", true, Guid.Parse("1d569b07-75b4-4e2f-b067-6583401a09c8"));

            await clusterRepository.AddAsync("Dummy test cluster #2", "lkc-9998", true, Guid.Parse("b8c32078-9eec-4809-8f4e-5efbe509b78f"));

            var response = await clusterController.GetAll();

            var okResult = response as OkObjectResult;

            Assert.Equal(
                expected: "[{\"Name\":\"Dummy test cluster #1\",\"Description\":\"\",\"Enabled\":true,\"ClusterId\":\"lkc-9999\",\"DomainEvents\":[],\"Id\":\"1d569b07-75b4-4e2f-b067-6583401a09c8\"},{\"Name\":\"Dummy test cluster #2\",\"Description\":\"\",\"Enabled\":true,\"ClusterId\":\"lkc-9998\",\"DomainEvents\":[],\"Id\":\"b8c32078-9eec-4809-8f4e-5efbe509b78f\"}]",
                actual: JsonSerializer.Serialize(okResult.Value)
                );
        }