Пример #1
0
        public void ConstructorShouldConstructWithSetters()
        {
            // Arrange
            var tenantId       = Guid.Parse("fa4d6c6e-9650-44c9-8c6b-5aebd3f9a67d");
            var email          = "*****@*****.**";
            var gender         = "Male";
            var firstName      = "Colt";
            var lastName       = "Clary";
            var addressId      = Guid.Parse("fa4d6c6e-9650-44c9-8c6b-5aebd3f9a67c");
            var roomId         = Guid.Parse("fa4d6c6e-9650-44c9-8c6b-5aebd3f9a67b");
            var carId          = 3;
            var batchId        = 3;
            var trainingCenter = Guid.Parse("fa4d6c6e-9650-44c9-8c6b-5aebd3f9a67b");
            // Act (set properties to variables through constructor)
            var apiTenant = new DatMod.Tenant
            {
                Id             = tenantId,
                Email          = email,
                Gender         = gender,
                FirstName      = firstName,
                LastName       = lastName,
                AddressId      = addressId,
                RoomId         = roomId,
                CarId          = carId,
                BatchId        = batchId,
                TrainingCenter = trainingCenter
            };

            // Assert (assure the values are set)

            Assert.Equal(tenantId, apiTenant.Id);
            Assert.Equal(email, apiTenant.Email);
            Assert.Equal(gender, apiTenant.Gender);
            Assert.Equal(firstName, apiTenant.FirstName);
            Assert.Equal(lastName, apiTenant.LastName);
            Assert.Equal(addressId, apiTenant.AddressId);
            Assert.Equal(roomId, apiTenant.RoomId);
            Assert.Equal(carId, apiTenant.CarId);
            Assert.Equal(batchId, apiTenant.BatchId);
            Assert.Equal(trainingCenter, apiTenant.TrainingCenter);
        }
Пример #2
0
        /// <summary>
        /// Map a Model Tenant from a Entity Tenant
        /// </summary>
        /// <param name="tenant">A Tenant Entity who may have a nested Car Model and/or a Batch Model</param>
        /// <returns>A Tenant Model who may have a nested Car Model and/or a Batch Model</returns>
        public Lib.Models.Tenant MapTenant(Entities.Tenant tenant)
        {
            Lib.Models.Batch batch;
            int?batchId;

            if (tenant.Batch != null)
            {
                batch = new Lib.Models.Batch
                {
                    Id = tenant.Batch.Id,
                    BatchCurriculum = tenant.Batch.BatchCurriculum,
                    TrainingCenter  = tenant.Batch.TrainingCenter
                };
                batch.SetStartAndEndDate(tenant.Batch.StartDate, tenant.Batch.EndDate);
                batchId = tenant.BatchId;
            }
            else
            {
                batch   = null;
                batchId = null;
            }

            Lib.Models.Car car;
            int?           carId;

            if (tenant.Car != null)
            {
                car = new Lib.Models.Car()
                {
                    Id           = tenant.Car.Id,
                    LicensePlate = tenant.Car.LicensePlate,
                    Make         = tenant.Car.Make,
                    Model        = tenant.Car.Model,
                    Color        = tenant.Car.Color,
                    Year         = tenant.Car.Year,
                    State        = tenant.Car.State
                };
                carId = tenant.CarId;
            }
            else
            {
                car   = null;
                carId = null;
            }

            return(new Lib.Models.Tenant
            {
                Id = tenant.Id,
                Email = tenant.Email,
                Gender = tenant.Gender,
                FirstName = tenant.FirstName,
                LastName = tenant.LastName,
                AddressId = tenant.AddressId,
                RoomId = tenant.RoomId,
                CarId = carId,
                BatchId = batchId,
                TrainingCenter = tenant.TrainingCenter,

                Car = car,
                Batch = batch
            });
        }