コード例 #1
0
ファイル: WhenMappingEnums.cs プロジェクト: xcolon/Mapster
        public void String_Is_Mapped_To_Enum()
        {
            var employee = new EmployeeWithStringEnum { Id = Guid.NewGuid(), Name = "Timuçin", Department = Departments.IT.ToString() };

            var dto = TypeAdapter.Adapt<EmployeeWithStringEnum, EmployeeDTO>(employee);

            dto.ShouldNotBeNull();

            dto.Id.ShouldEqual(employee.Id);
            dto.Name.ShouldEqual(employee.Name);
            dto.Department.ShouldEqual(Departments.IT);
        }
コード例 #2
0
ファイル: WhenMappingEnums.cs プロジェクト: wk-j/mapster
        public void String_Is_Mapped_To_Enum()
        {
            var employee = new EmployeeWithStringEnum {
                Id = Guid.NewGuid(), Name = "Timuçin", Department = Departments.IT.ToString()
            };

            var dto = TypeAdapter.Adapt <EmployeeWithStringEnum, EmployeeDTO>(employee);

            dto.ShouldNotBeNull();

            dto.Id.ShouldBe(employee.Id);
            dto.Name.ShouldBe(employee.Name);
            dto.Department.ShouldBe(Departments.IT);
        }
コード例 #3
0
ファイル: WhenMappingEnums.cs プロジェクト: xcolon/Mapster
        public void Null_String_Is_Mapped_To_Enum_Default()
        {
            TypeAdapterConfig<EmployeeWithStringEnum, EmployeeDTO>
                .NewConfig();

            var employee = new EmployeeWithStringEnum { Id = Guid.NewGuid(), Name = "Timuçin", Department = null };

            var dto = TypeAdapter.Adapt<EmployeeWithStringEnum, EmployeeDTO>(employee);

            dto.ShouldNotBeNull();

            dto.Id.ShouldEqual(employee.Id);
            dto.Name.ShouldEqual(employee.Name);
            dto.Department.ShouldEqual(Departments.Finance);
        }
コード例 #4
0
ファイル: WhenMappingEnums.cs プロジェクト: wk-j/mapster
        public void Empty_String_Is_Mapped_To_Enum_Default()
        {
            TypeAdapterConfig <EmployeeWithStringEnum, EmployeeDTO>
            .NewConfig();

            var employee = new EmployeeWithStringEnum {
                Id = Guid.NewGuid(), Name = "Timuçin", Department = ""
            };

            var dto = TypeAdapter.Adapt <EmployeeWithStringEnum, EmployeeDTO>(employee);

            dto.ShouldNotBeNull();

            dto.Id.ShouldBe(employee.Id);
            dto.Name.ShouldBe(employee.Name);
            dto.Department.ShouldBe(Departments.Finance);
        }