public static void Initialize(ExampleContext context) { context.Database.EnsureCreated(); if (context.ExampleThings.Any()) { return; } var things = new ExampleThing[] { new ExampleThing { Title = "First item", Data = "Bunch of random data" }, new ExampleThing { Title = "Second item", Data = "Even more random data" }, new ExampleThing { Title = "Last item", Data = "A substantially larger amount of random data purely for the purpose of an example" }, }; foreach (ExampleThing t in things) { context.ExampleThings.Add(t); } context.SaveChanges(); }
public void WhenSerializingEmptyCollection_ItShouldBeIgnored() { var thing = new ExampleThing { Messages = new List<string>() }; string json = OpenStackNet.Serialize(thing); Assert.DoesNotContain("messages", json); }
public void WhenSerializingEmptyCollection_ItShouldBeIgnored() { var thing = new ExampleThing { Messages = new List <string>() }; string json = OpenStackNet.Configuration.FlurlHttpSettings.JsonSerializer.Serialize(thing); Assert.DoesNotContain("messages", json); }
public void WhenDeserializingNullCollection_ItShouldUseAnEmptyCollection() { var thing = new ExampleThing{Messages = null}; string json = OpenStackNet.Serialize(thing); Assert.DoesNotContain("messages", json); var result = OpenStackNet.Deserialize<ExampleThing>(json); Assert.NotNull(result.Messages); Assert.Empty(result.Messages); }
public void WhenSerializingEmptyCollection_ItShouldBeIgnored() { OpenStackNet.Configure(); var thing = new ExampleThing { Messages = new List <string>() }; string json = JsonConvert.SerializeObject(thing); Assert.DoesNotContain("messages", json); }
public void WhenDeserializingNullCollection_ItShouldUseAnEmptyCollection() { var thing = new ExampleThing { Messages = null }; string json = OpenStackNet.Configuration.FlurlHttpSettings.JsonSerializer.Serialize(thing); Assert.DoesNotContain("messages", json); var result = OpenStackNet.Configuration.FlurlHttpSettings.JsonSerializer.Deserialize <ExampleThing>(json); Assert.NotNull(result.Messages); Assert.Empty(result.Messages); }
public void WhenDeserializingNullCollection_ItShouldUseAnEmptyCollection() { OpenStackNet.Configure(); var thing = new ExampleThing { Messages = null }; string json = JsonConvert.SerializeObject(thing); Assert.DoesNotContain("messages", json); var result = JsonConvert.DeserializeObject <ExampleThing>(json); Assert.NotNull(result.Messages); Assert.Empty(result.Messages); }