コード例 #1
0
        public void When_Building_A_Table_Omit_Non_Key_Schema_Attributes()
        {
            var tableRequestFactory = new DynamoDbTableFactory();
            var builder             = new DynamoDbTableBuilder(CreateClient());

            //act
            CreateTableRequest tableRequest = tableRequestFactory.GenerateCreateTableMapper <DynamoDbEntity>(
                new DynamoDbCreateProvisionedThroughput
                (
                    new ProvisionedThroughput {
                ReadCapacityUnits = 10, WriteCapacityUnits = 10
            },
                    new Dictionary <string, ProvisionedThroughput>
            {
                {
                    "GlobalSecondaryIndex", new ProvisionedThroughput {
                        ReadCapacityUnits = 10, WriteCapacityUnits = 10
                    }
                }
            }
                )
                );

            var modifiedTableRequest = builder.RemoveNonSchemaAttributes(tableRequest);

            //assert
            Assert.DoesNotContain(modifiedTableRequest.AttributeDefinitions, attr => attr.AttributeName == "StringProperty" && attr.AttributeType == ScalarAttributeType.S);
            Assert.DoesNotContain(modifiedTableRequest.AttributeDefinitions, attr => attr.AttributeName == "NumberProperty" && attr.AttributeType == ScalarAttributeType.N);
            Assert.DoesNotContain(modifiedTableRequest.AttributeDefinitions, attr => attr.AttributeName == "ByteArrayProperty" && attr.AttributeType == ScalarAttributeType.B);
            Assert.Contains(tableRequest.AttributeDefinitions, attr => attr.AttributeName == "Id" && attr.AttributeType == ScalarAttributeType.S);
            Assert.Contains(tableRequest.AttributeDefinitions, attr => attr.AttributeName == "RangeKey" && attr.AttributeType == ScalarAttributeType.S);
            Assert.Contains(tableRequest.AttributeDefinitions, attr => attr.AttributeName == "GlobalSecondaryId" && attr.AttributeType == ScalarAttributeType.S);
            Assert.Contains(tableRequest.AttributeDefinitions, attr => attr.AttributeName == "GlobalSecondaryRangeKey" && attr.AttributeType == ScalarAttributeType.S);
            Assert.Contains(tableRequest.AttributeDefinitions, attr => attr.AttributeName == "LocalSecondaryRangeKey" && attr.AttributeType == ScalarAttributeType.S);
        }
コード例 #2
0
        protected DynamoDBOutboxBaseTest()
        {
            Client = CreateClient();
            _dynamoDbTableBuilder = new DynamoDbTableBuilder(Client);
            //create a table request
            var createTableRequest = new DynamoDbTableFactory().GenerateCreateTableMapper <MessageItem>(
                new DynamoDbCreateProvisionedThroughput(
                    new ProvisionedThroughput {
                ReadCapacityUnits = 10, WriteCapacityUnits = 10
            },
                    new Dictionary <string, ProvisionedThroughput>
            {
                { "Outstanding", new ProvisionedThroughput {
                      ReadCapacityUnits = 10, WriteCapacityUnits = 10
                  } },
                { "Delivered", new ProvisionedThroughput {
                      ReadCapacityUnits = 10, WriteCapacityUnits = 10
                  } }
            }
                    ));

            TableName = createTableRequest.TableName;
            (bool exist, IEnumerable <string> tables)hasTables = _dynamoDbTableBuilder.HasTables(new string[] { TableName }).Result;
            if (!hasTables.exist)
            {
                var buildTable = _dynamoDbTableBuilder.Build(createTableRequest).Result;
                _dynamoDbTableBuilder.EnsureTablesReady(new[] { createTableRequest.TableName }, TableStatus.ACTIVE).Wait();
            }
        }
コード例 #3
0
        protected DynamoDBInboxBaseTest()
        {
            //required by AWS 2.2
            Environment.SetEnvironmentVariable("AWS_ENABLE_ENDPOINT_DISCOVERY", "false");

            Client = CreateClient();
            _dynamoDbTableBuilder = new DynamoDbTableBuilder(Client);
            //create a table request
            var createTableRequest = new DynamoDbTableFactory().GenerateCreateTableMapper <CommandItem <MyCommand> >(
                new DynamoDbCreateProvisionedThroughput(
                    new ProvisionedThroughput {
                ReadCapacityUnits = 10, WriteCapacityUnits = 10
            },
                    new Dictionary <string, ProvisionedThroughput>()
                    ));

            TableName = createTableRequest.TableName;
            (bool exist, IEnumerable <string> tables)hasTables = _dynamoDbTableBuilder.HasTables(new string[] { TableName }).Result;
            if (!hasTables.exist)
            {
                var buildTable = _dynamoDbTableBuilder.Build(createTableRequest).Result;
                _dynamoDbTableBuilder.EnsureTablesReady(new[] { createTableRequest.TableName }, TableStatus.ACTIVE).Wait();
            }
        }