Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Model;
- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace UnitTest
- {
- public class DbInitializer : DropCreateDatabaseAlways<Context>
- {
- protected override void Seed(Context context)
- {
- TypeInfrastructure typeInfrastructure1 = new TypeInfrastructure()
- {
- IdTypeInfrastructure = 1,
- Label="Magasin"
- };
- TypeInfrastructure typeInfrastructure2 = new TypeInfrastructure()
- {
- IdTypeInfrastructure = 2,
- Label = "Restaurant"
- };
- TypeInfrastructure typeInfrastructure3 = new TypeInfrastructure()
- {
- IdTypeInfrastructure = 3,
- Label="Chinois",
- CategoryInfrastructure = typeInfrastructure1
- };
- Infrastructure Infrastructure1 = new Infrastructure()
- {
- IdInfrastructure = 1,
- Name = "hong",
- WebAddress="",
- InfraAddress = "rue",
- InfraLocality = "namur",
- InfraPostalCode = "5023",
- GeolactionX= 50.4669,
- GeolactionY = 4.86444,
- TypeInfrastructure = typeInfrastructure3
- };
- Infrastructure Infrastructure2 = new Infrastructure()
- {
- IdInfrastructure = 1,
- Name = "hong",
- WebAddress="",
- InfraAddress = "rue",
- InfraLocality = "namur",
- InfraPostalCode = "5023",
- GeolactionX = 50.4669,
- GeolactionY = 4.86444,
- TypeInfrastructure = typeInfrastructure3
- };
- User user1 = new User()
- {
- IdUser = 1,
- FirstName = "julien",
- LastName = "heylen",
- Birthday = new DateTime(1995, 11, 15),
- Email = "julien.heylen@hotmail.be",
- isMale = true,
- UserAdress = "chemin des dix bonniers,4",
- UserLocality = "Perwez",
- UserPostalCode = "1360",
- Phone = "0498516704",
- Password = "123",
- Friends = new List<User>()
- };
- User user2 = new User()
- {
- IdUser = 2,
- FirstName = "user2",
- LastName = "user2",
- Birthday = new DateTime(1995, 11, 15),
- Email = "julien.heylen@hotmail.be",
- isMale = true,
- UserAdress = "chemin des dix bonniers,4",
- UserLocality = "Perwez",
- UserPostalCode = "1360",
- Phone = "0498516704",
- Password = "123",
- Friends = new List<User>()
- };
- User user3 = new User()
- {
- IdUser = 3,
- FirstName = "user3",
- LastName = "user3",
- Birthday = new DateTime(1995, 11, 15),
- Email = "julien.heylen@hotmail.be",
- isMale = true,
- UserAdress = "chemin des dix bonniers,4",
- UserLocality = "Perwez",
- UserPostalCode = "1360",
- Phone = "0498516704",
- Password = "123",
- Friends = new List<User>()
- };
- User user4 = new User()
- {
- IdUser = 4,
- FirstName = "user4",
- LastName = "user4",
- Birthday = new DateTime(1995, 11, 15),
- Email = "julien.heylen@hotmail.be",
- isMale = true,
- UserAdress = "chemin des dix bonniers,4",
- UserLocality = "Perwez",
- UserPostalCode = "1360",
- Phone = "0498516704",
- Password = "123",
- Friends = new List<User>()
- };
- user1.Friends.Add(user4);
- user4.Friends.Add(user1);
- context.Users.Add(user1);
- context.Users.Add(user2);
- context.Users.Add(user3);
- context.Users.Add(user4);
- context.TypeInfrastructures.Add(typeInfrastructure1);
- context.TypeInfrastructures.Add(typeInfrastructure2);
- context.TypeInfrastructures.Add(typeInfrastructure3);
- context.Infrastructures.Add(Infrastructure1);
- context.Infrastructures.Add(Infrastructure2);
- context.SaveChanges();
- }
- }
- }
Add Comment
Please, Sign In to add comment