Guest User

Untitled

a guest
Dec 20th, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.71 KB | None | 0 0
  1. using Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data.Entity;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace UnitTest
  10. {
  11. public class DbInitializer : DropCreateDatabaseAlways<Context>
  12. {
  13. protected override void Seed(Context context)
  14. {
  15.  
  16. TypeInfrastructure typeInfrastructure1 = new TypeInfrastructure()
  17. {
  18. IdTypeInfrastructure = 1,
  19. Label="Magasin"
  20.  
  21. };
  22. TypeInfrastructure typeInfrastructure2 = new TypeInfrastructure()
  23. {
  24. IdTypeInfrastructure = 2,
  25. Label = "Restaurant"
  26. };
  27. TypeInfrastructure typeInfrastructure3 = new TypeInfrastructure()
  28. {
  29. IdTypeInfrastructure = 3,
  30. Label="Chinois",
  31. CategoryInfrastructure = typeInfrastructure1
  32. };
  33. Infrastructure Infrastructure1 = new Infrastructure()
  34. {
  35. IdInfrastructure = 1,
  36. Name = "hong",
  37. WebAddress="",
  38. InfraAddress = "rue",
  39. InfraLocality = "namur",
  40. InfraPostalCode = "5023",
  41. GeolactionX= 50.4669,
  42. GeolactionY = 4.86444,
  43. TypeInfrastructure = typeInfrastructure3
  44.  
  45. };
  46. Infrastructure Infrastructure2 = new Infrastructure()
  47. {
  48. IdInfrastructure = 1,
  49. Name = "hong",
  50. WebAddress="",
  51. InfraAddress = "rue",
  52. InfraLocality = "namur",
  53. InfraPostalCode = "5023",
  54. GeolactionX = 50.4669,
  55. GeolactionY = 4.86444,
  56. TypeInfrastructure = typeInfrastructure3
  57.  
  58. };
  59. User user1 = new User()
  60. {
  61. IdUser = 1,
  62. FirstName = "julien",
  63. LastName = "heylen",
  64. Birthday = new DateTime(1995, 11, 15),
  65. Email = "julien.heylen@hotmail.be",
  66. isMale = true,
  67. UserAdress = "chemin des dix bonniers,4",
  68. UserLocality = "Perwez",
  69. UserPostalCode = "1360",
  70. Phone = "0498516704",
  71. Password = "123",
  72. Friends = new List<User>()
  73.  
  74. };
  75. User user2 = new User()
  76. {
  77. IdUser = 2,
  78. FirstName = "user2",
  79. LastName = "user2",
  80. Birthday = new DateTime(1995, 11, 15),
  81. Email = "julien.heylen@hotmail.be",
  82. isMale = true,
  83. UserAdress = "chemin des dix bonniers,4",
  84. UserLocality = "Perwez",
  85. UserPostalCode = "1360",
  86. Phone = "0498516704",
  87. Password = "123",
  88. Friends = new List<User>()
  89. };
  90.  
  91.  
  92. User user3 = new User()
  93. {
  94. IdUser = 3,
  95. FirstName = "user3",
  96. LastName = "user3",
  97. Birthday = new DateTime(1995, 11, 15),
  98. Email = "julien.heylen@hotmail.be",
  99. isMale = true,
  100. UserAdress = "chemin des dix bonniers,4",
  101. UserLocality = "Perwez",
  102. UserPostalCode = "1360",
  103. Phone = "0498516704",
  104. Password = "123",
  105. Friends = new List<User>()
  106.  
  107. };
  108.  
  109. User user4 = new User()
  110. {
  111. IdUser = 4,
  112. FirstName = "user4",
  113. LastName = "user4",
  114. Birthday = new DateTime(1995, 11, 15),
  115. Email = "julien.heylen@hotmail.be",
  116. isMale = true,
  117. UserAdress = "chemin des dix bonniers,4",
  118. UserLocality = "Perwez",
  119. UserPostalCode = "1360",
  120. Phone = "0498516704",
  121. Password = "123",
  122. Friends = new List<User>()
  123. };
  124.  
  125. user1.Friends.Add(user4);
  126. user4.Friends.Add(user1);
  127.  
  128.  
  129. context.Users.Add(user1);
  130. context.Users.Add(user2);
  131. context.Users.Add(user3);
  132. context.Users.Add(user4);
  133. context.TypeInfrastructures.Add(typeInfrastructure1);
  134. context.TypeInfrastructures.Add(typeInfrastructure2);
  135. context.TypeInfrastructures.Add(typeInfrastructure3);
  136. context.Infrastructures.Add(Infrastructure1);
  137. context.Infrastructures.Add(Infrastructure2);
  138. context.SaveChanges();
  139. }
  140.  
  141. }
  142. }
Add Comment
Please, Sign In to add comment