public async Task Should_write_and_read_enums_and_value_types()
    {
        var entity = new TestEntity_with_Enum_and_ValueObjects
        {
            Id       = new Guid("A53F60CD-B53E-40E3-B16F-05E9A223E238"),
            TestEnum = TestEnum.Item1,
            IntBasedReferenceValueObject     = IntBasedReferenceValueObject.Create(42),
            IntBasedStructValueObject        = IntBasedStructValueObject.Create(43),
            StringBasedReferenceValueObject  = StringBasedReferenceValueObject.Create("value 1"),
            StringBasedStructValueObject     = StringBasedStructValueObject.Create("value 2"),
            TestSmartEnum_Struct_IntBased    = TestSmartEnum_Struct_IntBased.Value1,
            TestSmartEnum_Struct_StringBased = TestSmartEnum_Struct_StringBased.Value1,
            Boundary = Boundary.Create(10, 20)
        };

        _ctx.Add(entity);
        await _ctx.SaveChangesAsync();

        _ctx.ChangeTracker.Clear();
        (await _ctx.TestEntities_with_Enum_and_ValueObjects.SingleAsync())
        .Should().BeEquivalentTo(entity);
    }
    public void Should_return_nullable_key_if_value_type_is_struct_and_key_is_struct()
    {
        var value = (int?)IntBasedStructValueObject.Create(42);

        value.Should().Be(42);
    }
    public void Should_return_valid_instance_if_converted_to_nullable_type_of_itself()
    {
        IntBasedStructValueObject?valueObject = IntBasedStructValueObject.Create(42);

        IntBasedStructValueObjectTypeConverter.ConvertTo(valueObject, typeof(IntBasedStructValueObject?)).Should().Be(valueObject.Value);
    }
    public void Should_return_self_if_converted_to_itself()
    {
        var valueObject = IntBasedStructValueObject.Create(42);

        IntBasedStructValueObjectTypeConverter.ConvertTo(valueObject, typeof(IntBasedStructValueObject)).Should().Be(valueObject);
    }
 public void Should_return_key_if_value_type_is_struct_and_key_matches_the_struct_key()
 {
     IntBasedStructValueObjectTypeConverter.ConvertTo(IntBasedStructValueObject.Create(42), typeof(int)).Should().Be(42);
 }
示例#6
0
    public void Should_return_self_if_converted_from_itself()
    {
        var valueObject = IntBasedStructValueObject.Create(42);

        IntBasedStructValueObjectTypeConverter.ConvertFrom(valueObject).Should().Be(valueObject);
    }
示例#7
0
 public void Should_return_valid_instance_if_value_type_is_struct_and_key_matches_the_struct_key()
 {
     IntBasedStructValueObjectTypeConverter.ConvertFrom(42).Should().BeEquivalentTo(IntBasedStructValueObject.Create(42));
 }