Пример #1
0
        public static async Task AssertItemAsync(
            this IAmazonDynamoDB db,
            string tableName,
            Dictionary <string, AttributeValue> key,
            Dictionary <string, AttributeValue> expectedItem
            )
        {
            GetItemRequest request = new GetItemRequest {
                TableName      = tableName,
                Key            = key,
                ConsistentRead = true
            };

            GetItemResponse response = await db
                                       .GetItemAsync(request)
                                       .ConfigureAwait(false);

            if (!response.IsItemSet)
            {
                Assert.Fail("Item should exist.");
            }

            AttributeValueAssert.AreEqual(
                actual: response.Item,
                expected: expectedItem
                );
        }
Пример #2
0
 public void AreEqual_Dictionary_WhenEquivalent(
     Dictionary <string, AttributeValue> x,
     Dictionary <string, AttributeValue> y
     )
 {
     AttributeValueAssert.AreEqual(x, y);
 }
Пример #3
0
 public void AreEqual_Null_WhenEqual([Values] bool value)
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         NULL = value
     },
         new AttributeValue {
         NULL = value
     }
         );
 }
Пример #4
0
 public void AreEqual_Numeric_WhenEqual(byte[] bytes)
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         B = new MemoryStream(bytes)
     },
         new AttributeValue {
         B = new MemoryStream(bytes)
     }
         );
 }
Пример #5
0
 public void AreEqual_Boolean_WhenEqual([Values] bool value)
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         BOOL = value
     },
         new AttributeValue {
         BOOL = value
     }
         );
 }
Пример #6
0
 public void AreEqual_String_WhenEqual(string value)
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         S = value
     },
         new AttributeValue {
         S = value
     }
         );
 }
Пример #7
0
 public void AreEqual_Numeric_WhenEqual(string value)
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         N = value
     },
         new AttributeValue {
         N = value
     }
         );
 }
Пример #8
0
 public void AreEqual_BinarySet_WhenEquivalent(
     List <MemoryStream> x,
     List <MemoryStream> y
     )
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         BS = x
     },
         new AttributeValue {
         BS = y
     }
         );
 }
Пример #9
0
 public void AreEqual_Map_WhenEquivalent(
     Dictionary <string, AttributeValue> x,
     Dictionary <string, AttributeValue> y
     )
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         M = x
     },
         new AttributeValue {
         M = y
     }
         );
 }
Пример #10
0
 public void AreEqual_StringSet_WhenEquivalent(
     List <string> x,
     List <string> y
     )
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         SS = x
     },
         new AttributeValue {
         SS = y
     }
         );
 }
Пример #11
0
 public void AreEqual_List_WhenEquivalent(
     List <AttributeValue> x,
     List <AttributeValue> y
     )
 {
     AttributeValueAssert.AreEqual(
         new AttributeValue {
         L = x
     },
         new AttributeValue {
         L = y
     }
         );
 }
Пример #12
0
        public void AreEqual_Dictionary_WhenNotEqual(
            Dictionary <string, AttributeValue> x,
            Dictionary <string, AttributeValue> y,
            string expectedMessage
            )
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(x, y);
            });

            Assert.That(
                err.Message,
                Does.StartWith(expectedMessage)
                );
        }
Пример #13
0
        public void AreEqual_Null_WhenNotEqual()
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    NULL = true
                },
                    new AttributeValue {
                    NULL = false
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  NULL must be equal")
                );
        }
Пример #14
0
        public void AreEqual_Numeric_WhenNotEqual(string x, string y)
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    N = "33"
                },
                    new AttributeValue {
                    N = "45"
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  N must be equal")
                );
        }
Пример #15
0
        public void AreEqual_String_WhenNotEqual()
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    S = "x"
                },
                    new AttributeValue {
                    S = "y"
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  S must be equal")
                );
        }
Пример #16
0
        public void AreEqual_Boolean_WhenBooleanNotSet()
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    BOOL = true
                },
                    new AttributeValue {
                    S = "abc"
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  IsBOOLSet must be equal")
                );
        }
Пример #17
0
        public void AreEqual_Numeric_WhenNotEqual(
            byte[] x,
            byte[] y
            )
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    B = new MemoryStream(x)
                },
                    new AttributeValue {
                    B = new MemoryStream(y)
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  B must be equal")
                );
        }
Пример #18
0
        public void AreEqual_BinarySet_WhenNotEqual(
            List <MemoryStream> x,
            List <MemoryStream> y
            )
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    BS = x
                },
                    new AttributeValue {
                    BS = y
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  BS must be equivalent")
                );
        }
Пример #19
0
        public void AreEqual_StringSet_WhenNotEqual(
            List <string> x,
            List <string> y
            )
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    SS = x
                },
                    new AttributeValue {
                    SS = y
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  SS must be equivalent")
                );
        }
Пример #20
0
        public void AreEqual_Map_WhenMapNotSet()
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    M = new Dictionary <string, AttributeValue> {
                        { "x", new AttributeValue {
                              N = "23.88"
                          } }
                    }
                },
                    new AttributeValue {
                    S = "abc"
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  IsMSet must be equal")
                );
        }
Пример #21
0
        public void AreEqual_List_WhenNotEqual(
            List <AttributeValue> x,
            List <AttributeValue> y,
            string expectedMessage
            )
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    L = x
                },
                    new AttributeValue {
                    L = y
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith(expectedMessage)
                );
        }
Пример #22
0
        public void AreEqual_List_WhenListNotSet()
        {
            var err = Assert.Throws <AssertionException>(() => {
                AttributeValueAssert.AreEqual(
                    new AttributeValue {
                    L = new List <AttributeValue> {
                        new AttributeValue {
                            N = "23.88"
                        }
                    }
                },
                    new AttributeValue {
                    S = "abc"
                }
                    );
            });

            Assert.That(
                err.Message,
                Does.StartWith("  IsLSet must be equal")
                );
        }