public void Collection_OfObjects_MapsToLAttribute() { var lst = new[] { new { MyValue = "Value" } }; AttributeValue sut = EasyAttributeValue.FromCollection(lst); var expectedValue = new[] { new AttributeValue { M = new Dictionary <string, AttributeValue> { { "MyValue", new AttributeValue { S = "Value" } } } } }; using (new AssertionScope()) { sut.L.Should().HaveCount(lst.Count()); sut.L.Should().BeEquivalentTo(expectedValue); } }
public void AttributesAreMappedToMAttribute() { dynamic value = new { NumericValue = 1, StringValue = "StringValue" }; var values = new Dictionary <string, AttributeValue> { { nameof(value.NumericValue), new EasyAttributeValue(value.NumericValue) }, { nameof(value.StringValue), new EasyAttributeValue(value.StringValue) } }; var sut = EasyAttributeValue.FromProperties(values); AttributeValue projection = sut; using (new AssertionScope()) { projection.IsMSet.Should().BeTrue(); projection.M.Should().NotBeNull(); projection.M.Should().BeEquivalentTo(values); } }
public void BoolValuesAreMappedToBooleanType(bool value) { var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.BOOL.Should().Be(value); }
public void Enum_GetsParsedAs_StringValue() { var val = MyEnum.EnumValue; AttributeValue sut = new EasyAttributeValue(val); sut.S.Should().Be(Enum.GetName(typeof(MyEnum), val)); }
public void NullStringsValuesAreMappedToStringType() { const string value = null; var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.S.Should().BeNull(); }
public void StringValuesAreMappedToStringType() { const string value = nameof(value); var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.S.Should().Be(value); }
public void DecimalValuesAreMappedToNumberType() { const decimal value = 4.0m; var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.N.Should().Be(value.ToString()); }
public void FloatValuesAreMappedToNumberType() { const float value = 4.0F; var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.N.Should().Be(value.ToString()); }
public void DateTimeValuesAreMappedToISODateString() { var value = DateTime.UtcNow; var sut = new EasyAttributeValue(value); AttributeValue projection = sut; projection.S.Should().Be(value.ToString("o")); }
public void Object_WithNestedObject_MappedToMAttribute() { var value = new { NestedValue = new { NumericValue = 1, StringValue = "StringValue", BooleanValue = true, DateTimeValue = DateTime.Now, DateTimeOffsetValue = DateTimeOffset.Now } }; var sut = EasyAttributeValue.FromObject(value); AttributeValue projection = sut; using (new AssertionScope()) { projection.IsMSet.Should().BeTrue(); projection.M.Should().NotBeNull(); projection.M.Should().ContainKey(nameof(value.NestedValue)); var nestedAttribute = projection.M[nameof(value.NestedValue)]; nestedAttribute.M.Should().ContainKey(nameof(value.NestedValue.NumericValue)); nestedAttribute.M[nameof(value.NestedValue.NumericValue)].Should().BeEquivalentTo(new AttributeValue { N = value.NestedValue.NumericValue.ToString() }); nestedAttribute.M.Should().ContainKey(nameof(value.NestedValue.StringValue)); nestedAttribute.M[nameof(value.NestedValue.StringValue)].Should().BeEquivalentTo(new AttributeValue { S = value.NestedValue.StringValue }); nestedAttribute.M.Should().ContainKey(nameof(value.NestedValue.BooleanValue)); nestedAttribute.M[nameof(value.NestedValue.BooleanValue)].Should().BeEquivalentTo(new AttributeValue { BOOL = value.NestedValue.BooleanValue }); nestedAttribute.M.Should().ContainKey(nameof(value.NestedValue.DateTimeValue)); nestedAttribute.M[nameof(value.NestedValue.DateTimeValue)].Should().BeEquivalentTo(new AttributeValue { S = value.NestedValue.DateTimeValue.ToString("O") }); nestedAttribute.M.Should().ContainKey(nameof(value.NestedValue.DateTimeOffsetValue)); nestedAttribute.M[nameof(value.NestedValue.DateTimeOffsetValue)].Should().BeEquivalentTo(new AttributeValue { S = value.NestedValue.DateTimeOffsetValue.ToString("O") }); } }
public void Collection_OfPrimitiveValues_MapsToLAttribute() { var lst = Enumerable.Range(1, 2); AttributeValue sut = EasyAttributeValue.FromCollection(lst); var expectedValues = lst.Select(v => new AttributeValue { N = v.ToString() }); using (new AssertionScope()) { sut.L.Should().HaveCount(lst.Count()); sut.L.Should().BeEquivalentTo(expectedValues); } }
public void Object_WithEnumProperty_MapsEnumProperty() { var value = new { NestedEnum = MyEnum.EnumValue }; AttributeValue sut = EasyAttributeValue.FromObject(value); using (new AssertionScope()) { sut.IsMSet.Should().BeTrue(); sut.M.Should().NotBeNull(); sut.M.Should().ContainKey(nameof(value.NestedEnum)); var nestedAttribute = sut.M[nameof(value.NestedEnum)]; nestedAttribute.S.Should().Be(Enum.GetName(typeof(MyEnum), value.NestedEnum)); } }