public void LoadTemplateTest() { var data = TemplateConfig.ReadDefaultTemplate(); //output.WriteLine(JsonConvert.SerializeObject(data)); Assert.True(data.Count > 0); }
public ServiceTest(ITestOutputHelper output) { this.output = output; gxDb = new GxContextFactory().CreateDbContext(new string[] { "test" }); userService = new UserService(gxDb); projectService = new ProjectService(gxDb); propertyService = new PropertyService(gxDb); // add property var data = TemplateConfig.ReadDefaultTemplate(); propertyService.AddProperties(data); //add template var template = new PropertyTemplate() { Name = "Default" }; //add template-property List <Template_Property> template_s = new List <Template_Property>(data.Count); foreach (var item in data) { template_s.Add(new Template_Property() { PropertyTemplate = template, GxProperty = item }); } template.Template_Properties = template_s; gxDb.PropertyTemplates.Add(template); gxDb.SaveChanges(); //add user data User[] users = new User[] { new User() { Name = "Jack", PassWord = "******" }, new User() { Name = "Andy", PassWord = "******" }, new User() { Name = "Frank", PassWord = "******" }, new User() { Name = "张山", PassWord = "******" } }; foreach (var user in users) { if (userService.Register(user.Name, user.PassWord)) { output.WriteLine($"{user.Name}注册成功!"); } else { output.WriteLine($"{user.Name}注册失败,用户名已存在!"); } } //add project User u = userService.Login("Jack", "123"); Project project = new Project() { Creator = u, Name = "Test Project1" }; project.PropertyTemplate = template; userService.CreateProject(u, ref project); }