Esempio n. 1
0
        private void TestLoadSuccess()
        {
            Option <JObject> actualJsonObject = dynamoDbMetastoreImpl.Load(TestKey, created);

            Assert.True(actualJsonObject.IsSome);
            Assert.True(JToken.DeepEquals(JObject.FromObject(keyRecord), (JObject)actualJsonObject));
        }
        private void TestBuilderPathWithTableName()
        {
            const string tempTableName = "DummyTable";

            // Use AWS SDK to create client
            AmazonDynamoDBConfig amazonDynamoDbConfig = new AmazonDynamoDBConfig
            {
                ServiceURL           = "http://localhost:8000",
                AuthenticationRegion = "us-west-2",
            };
            AmazonDynamoDBClient tempDynamoDbClient = new AmazonDynamoDBClient(amazonDynamoDbConfig);

            CreateTableSchema(tempDynamoDbClient, tempTableName);

            // Put the object in temp table
            Table    tempTable = Table.LoadTable(tempDynamoDbClient, tempTableName);
            JObject  jObject   = JObject.FromObject(keyRecord);
            Document document  = new Document
            {
                [PartitionKey]       = TestKey,
                [SortKey]            = created.ToUnixTimeSeconds(),
                [AttributeKeyRecord] = Document.FromJson(jObject.ToString()),
            };

            tempTable.PutItemAsync(document).Wait();

            // Create a metastore object using the withTableName step
            DynamoDbMetastoreImpl dbMetastoreImpl = NewBuilder(Region)
                                                    .WithEndPointConfiguration("http://localhost:" + DynamoDbPort, "us-west-2")
                                                    .WithTableName(tempTableName)
                                                    .Build();
            Option <JObject> actualJsonObject = dbMetastoreImpl.Load(TestKey, created);

            // Verify that we were able to load and successfully decrypt the item from the metastore object created withTableName
            Assert.True(actualJsonObject.IsSome);
            Assert.True(JToken.DeepEquals(JObject.FromObject(keyRecord), (JObject)actualJsonObject));
        }