public void Validate_Multiple_Entities() { using (var context = new CodeCampContext(TestHelpers.TestDatabaseName)) { Speaker speaker = new Speaker { FirstName = "Test", Presentations = new Collection <Presentation>(new[] { new Presentation() }) }; Presentation presentation = new Presentation { Speaker = new Speaker() }; CodeCampEvent codeCamp = new CodeCampEvent { Topics = new Collection <EventSession>(new [] { new EventSession { Presentation = presentation } }) }; context.Speakers.Add(speaker); context.CodeCampEvents.Add(codeCamp); TestHelpers.WriteValiationResults(context); } }
public void Validate_With_IValidatableObject() { using (var context = new CodeCampContext(TestHelpers.TestDatabaseName)) { // IValidatableObject Validate method is not called if validation attributes fail first. CodeCampEvent codeCamp = new CodeCampEvent(); Console.WriteLine("Code Camp Valdation check 1"); TestHelpers.WriteValiationResults(context, codeCamp); // IValidatableObject Validate method is called because validation attributes passed. Console.WriteLine("\nCode Camp Valdation check 2"); codeCamp.Location.Name = "Event Name"; TestHelpers.WriteValiationResults(context, codeCamp); Console.WriteLine("\nCode Camp Valdation check 3"); codeCamp.StartDate = DateTime.Today; codeCamp.EndDate = DateTime.Today.AddDays(1); codeCamp.Location.State = "NC"; TestHelpers.WriteValiationResults(context, codeCamp); } }
protected override void Seed(CodeCampContext context) { //base.Seed(context); // Speakers with Presentations var steveSuing = new Speaker { FirstName = "Steve", LastName = "Suing", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Rest API's" } }) }; var mattDuffied = new Speaker { FirstName = "Matt", LastName = "Duffield", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Building Windows Phone 7 apps with JSON" } }) }; var kevinHennessy = new Speaker { FirstName = "Kevin", LastName = "Hennessy", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Using Knockout JS" } }) }; var robZelt = new Speaker { FirstName = "Rob", LastName = "Zelt", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "WinRT - What Art Thou? A Developers look at Windows 8" } }) }; var jamesDixon = new Speaker { FirstName = "James", LastName = "Dixon", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Unit testing your voice activated toaster" } }) }; var chipBurris = new Speaker { FirstName = "Chip", LastName = "Burris", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Mobile Web APP support in MVC 4" } }) }; var dianeWilson = new Speaker { FirstName = "Diane", LastName = "Wilson", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Remedial LING" } }) }; var chrisEargle = new Speaker { FirstName = "Chris", LastName = "Eargle", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "Secrets of a .NET Ninja" }, new Presentation { Title = "The Legend of Lamda" } }) }; var gregPugh = new Speaker { FirstName = "Greg", LastName = "Pugh", Email = "*****@*****.**", Presentations = new Collection <Presentation>(new[] { new Presentation { Title = "What ever he dreamed up the night before." } }) }; context.Speakers.Add(steveSuing); context.Speakers.Add(mattDuffied); context.Speakers.Add(kevinHennessy); context.Speakers.Add(jamesDixon); context.Speakers.Add(robZelt); context.Speakers.Add(chipBurris); context.Speakers.Add(dianeWilson); context.Speakers.Add(chrisEargle); context.Speakers.Add(gregPugh); // Code Camp var codeCamp = new CodeCampEvent { Title = "RDU Code Camp", Location = new Location { Name = "ECPI College of Technology", StreetAddress1 = "4101 Doie Cope Road", City = "Raleigh", State = "NC" }, StartDate = new DateTime(2012, 11, 3, 8, 0, 0), EndDate = new DateTime(2012, 11, 3, 17, 30, 0), Topics = new Collection <EventSession>(new[] { new EventSession { StartTime = new DateTime(2012, 11, 3, 9, 30, 0), Room = "206", Track = "Web Development", SessionType = SessionType.Presentation, Presentation = steveSuing.Presentations. ElementAtOrDefault(0) }, new EventSession { StartTime = new DateTime(2012, 11, 3, 9, 30, 0), Room = "223", Track = "General Track", SessionType = SessionType.Presentation, Presentation = chrisEargle.Presentations. ElementAtOrDefault(0) }, new EventSession { StartTime = new DateTime(2012, 11, 3, 14, 30, 0), Room = "230", Track = "General Track", SessionType = SessionType.Presentation, Presentation = chrisEargle.Presentations. ElementAtOrDefault(1) }, }) }; context.CodeCampEvents.Add(codeCamp); }