Exemplo n.º 1
0
        public void CanCreateDtoWithEntity() {
            Region region = new Region("Eastern");
            region.SetAssignedIdTo(1);

            RegionDto regionDto = RegionDto.Create(region);

            regionDto.Id.ShouldEqual(1);
            regionDto.Description.ShouldEqual("Eastern");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Transfers the region entity's property values to the DTO.
        /// Strongly consider Jimmy Bogard's AutoMapper (http://automapper.codeplex.com/) 
        /// for doing this kind of work in a more automated fashion.
        /// </summary>
        public static RegionDto Create(Region region) {
            if (region == null)
                return null;

            return new RegionDto() {
                Id = region.Id,
                Description = region.Description
            };
        }
        protected override void LoadTestData() {
            Region region = new Region("Northern");
            region.SetAssignedIdTo(1);
            regionRepository.Save(region);
            FlushSessionAndEvict(region);

            Territory territory = new Territory("Troy", region);
            territory.SetAssignedIdTo("48084");
            territoryRepository.Save(territory);
            FlushSessionAndEvict(territory);

            Employee employee = new Employee("Joe", "Smith");
            employee.Territories.Add(territory);
            employeeRepository.SaveOrUpdate(employee);
            FlushSessionAndEvict(employee);
        }