public async Task DescribeSubnetsAsync_when_any_exist_should_describe_subnets() { // Arrange var client = new EnvironmentVariables().CloudComputeClient(); ISubnetService classUnderTest = new SubnetService(client); // Act var response = await classUnderTest.DescribeSubnetsAsync(); // Assert Assert.IsTrue(response.Subnets.Count >= 1); }
public async Task DeleteSubnetAsync_when_vpcId_exists_should_delete() { // Arrange var subnetId = "subnet-0c7f1fd88bd8b7694"; var client = new EnvironmentVariables().CloudComputeClient(); ISubnetService classUnderTest = new SubnetService(client); // Act var response = await classUnderTest.DeleteSubnetAsync(subnetId); // Assert Assert.IsTrue(response.HttpStatusCode == System.Net.HttpStatusCode.OK); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); // appsettings.json var awsAccessKeyId = Configuration.GetSection("AwsAccessKeyId").Value; var awsSecretAccessKey = Configuration.GetSection("AwsSecretAccessKey").Value; var keyService = new KeyService(awsAccessKeyId, awsSecretAccessKey); // Amazon clients // `keyService` can be used to pass `AwsAccessKeyId` and `AwsSecretAccessKey` var cloudComputeClient = new AmazonEC2Client(); var containerServiceClient = new AmazonECSClient(); var containerRegistryClient = new AmazonECRClient(); services.AddSingleton <IKeyService>(keyService); services.AddSingleton <IAmazonEC2>(cloudComputeClient); services.AddSingleton <IAmazonECS>(containerServiceClient); services.AddSingleton <IAmazonECR>(containerRegistryClient); // AwsAdmin.Application Services var vpcService = new VpcService(cloudComputeClient); var subnetService = new SubnetService(cloudComputeClient); var routeTableService = new RouteTableService(cloudComputeClient); var internetGatewayService = new InternetGatewayService(cloudComputeClient); var dhcpOptionsSetService = new DhcpOptionsSetService(cloudComputeClient); var networkAclsService = new NetworkAclsService(cloudComputeClient); var securityGroupService = new SecurityGroupService(cloudComputeClient); services.AddSingleton <IVpcService>(vpcService); services.AddSingleton <ISubnetService>(subnetService); services.AddSingleton <IRouteTableService>(routeTableService); services.AddSingleton <IInternetGatewayService>(internetGatewayService); services.AddSingleton <IDhcpOptionsSetService>(dhcpOptionsSetService); services.AddSingleton <INetworkAclsService>(networkAclsService); services.AddSingleton <ISecurityGroupService>(securityGroupService); // Mappers services.AddSingleton <IDescribeVpcMapper, DescribeVpcMapper>(); services.AddSingleton <IDescribeSubnetMapper, DescribeSubnetMapper>(); services.AddSingleton <IDescribeRouteTableMapper, DescribeRouteTableMapper>(); services.AddSingleton <IDhcpOptionsSetsMapper, DhcpOptionsSetsMapper>(); services.AddSingleton <IInternetGatewayMapper, InternetGatewayMapper>(); services.AddSingleton <INetworkAclsMapper, NetworkAclsMapper>(); services.AddSingleton <ISecurityGroupMapper, SecurityGroupMapper>(); }
public async Task CreateSubnetAsync_should_create_and_return_subnet() { // Arrange var vpcId = "vpc-0207f5e6f8ccfb5d8"; var cidrBlock1 = "10.0.1.0/24"; var cidrBlock2 = "10.0.0.0/24"; var client = new EnvironmentVariables().CloudComputeClient(); ISubnetService classUnderTest = new SubnetService(client); // Act var response = await classUnderTest.CreateSubnetAsync(vpcId, cidrBlock1); var response2 = await classUnderTest.CreateSubnetAsync(vpcId, cidrBlock2); // Assert Assert.IsTrue(response.Subnet != null); Assert.IsTrue(response.Subnet.SubnetId.Length > 1); }