Пример #1
0
        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
        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
        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
        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);
        }