private void button1AddMullusk_Click(object sender, EventArgs e) { string molluskType; string name = textBox1Name.Text; int sizeInCm = int.Parse(textBox2Size.Text); int minTemp = int.Parse(textBox3MinTemp.Text); int maxTemp = int.Parse(textBox4MaxTemp.Text); string color = textBox5Color.Text; if (radioButton3Starfish.Checked) { molluskType = radioButton3Starfish.Text; starFish = new Starfish(); aquarium.AllAnimalsCollection.Add(starFish); aquarium.MolluskCollection.Add(starFish); starFish.Img = FishGUI.Properties.Resources.starfish_icon; starFish.XPossition = locationGenerator.Next(Аquarium.xMinValue + 100, Аquarium.xMaxValue); starFish.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 20, Аquarium.yMaxValue); } if (radioButton1Octopus.Checked) { molluskType = radioButton1Octopus.Text; octopus = new Octopus(); octopus.AnimalName = name; aquarium.AllAnimalsCollection.Add(octopus); aquarium.MolluskCollection.Add(octopus); octopus.Img = FishGUI.Properties.Resources.octopus_icon; octopus.XPossition = locationGenerator.Next(Аquarium.xMinValue + 300, Аquarium.xMaxValue); octopus.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 200, Аquarium.yMaxValue); } if (radioButton2Snail.Checked) { molluskType = radioButton2Snail.Text; snail = new Snail(); aquarium.AllAnimalsCollection.Add(snail); aquarium.MolluskCollection.Add(snail); snail.Img = FishGUI.Properties.Resources.Snail_icon; snail.XPossition = locationGenerator.Next(Аquarium.xMinValue + 500, Аquarium.xMaxValue); snail.YPossition = locationGenerator.Next(Аquarium.yMaxValue - 400, Аquarium.yMaxValue); } this.DialogResult = DialogResult.OK; }
public static void Serializer_serializes_concrete_type_whose_abstract_parent_is_TwoWay_bindable_with_type_information_written_into_the_json() { var starfish = new Starfish(); var crab = new Crab(SeaCreatureSize.Large); var salmon = new Salmon(SeaCreatureSize.Medium, "brown"); var expectedStarfishJson = Invariant($"{{\r\n \"$concreteType\": \"OBeautifulCode.Serialization.Json.Test.JsonSerializationConfigurationTest+Starfish, OBeautifulCode.Serialization.Json.Test\"\r\n}}"); var expectedCrabJson = Invariant($"{{\r\n \"size\": \"large\",\r\n \"$concreteType\": \"OBeautifulCode.Serialization.Json.Test.JsonSerializationConfigurationTest+Crab, OBeautifulCode.Serialization.Json.Test\"\r\n}}"); var expectedSalmonJson = Invariant($"{{\r\n \"color\": \"brown\",\r\n \"size\": \"medium\",\r\n \"$concreteType\": \"OBeautifulCode.Serialization.Json.Test.JsonSerializationConfigurationTest+Salmon, OBeautifulCode.Serialization.Json.Test\"\r\n}}"); var actualStarfishJson = new ObcJsonSerializer(typeof(SeaCreatureJsonSerializationConfiguration).ToJsonSerializationConfigurationType()).SerializeToString(starfish); var actualCrabJson = new ObcJsonSerializer(typeof(SeaCreatureJsonSerializationConfiguration).ToJsonSerializationConfigurationType()).SerializeToString(crab); var actualSalmonJson = new ObcJsonSerializer(typeof(SeaCreatureJsonSerializationConfiguration).ToJsonSerializationConfigurationType()).SerializeToString(salmon); expectedStarfishJson.Should().Be(actualStarfishJson); expectedCrabJson.Should().Be(actualCrabJson); expectedSalmonJson.Should().Be(actualSalmonJson); }
public static void Serializer_serializes_concrete_type_whose_abstract_parent_is_TwoWay_bindable_with_type_information_written_into_the_json() { var starfish = new Starfish(); var crab = new Crab(SeaCreatureSize.Large); var salmon = new Salmon(SeaCreatureSize.Medium, "brown"); var expectedStarfishJson = "{\r\n \"$concreteType\": \"Naos.Serialization.Test.JsonConfigurationTest+Starfish, Naos.Serialization.Test\"\r\n}"; var expectedCrabJson = "{\r\n \"size\": \"large\",\r\n \"$concreteType\": \"Naos.Serialization.Test.JsonConfigurationTest+Crab, Naos.Serialization.Test\"\r\n}"; var expectedSalmonJson = "{\r\n \"color\": \"brown\",\r\n \"size\": \"medium\",\r\n \"$concreteType\": \"Naos.Serialization.Test.JsonConfigurationTest+Salmon, Naos.Serialization.Test\"\r\n}"; var actualStarfishJson = new NaosJsonSerializer(typeof(GenericDiscoveryJsonConfiguration <SeaCreature>)).SerializeToString(starfish); var actualCrabJson = new NaosJsonSerializer(typeof(GenericDiscoveryJsonConfiguration <SeaCreature>)).SerializeToString(crab); var actualSalmonJson = new NaosJsonSerializer(typeof(GenericDiscoveryJsonConfiguration <SeaCreature>)).SerializeToString(salmon); expectedStarfishJson.Should().Be(actualStarfishJson); expectedCrabJson.Should().Be(actualCrabJson); expectedSalmonJson.Should().Be(actualSalmonJson); }
public void Serializer_serializes_concrete_type_whose_abstract_parent_is_TwoWay_bindable_with_type_information_written_into_the_json() { var starfish = new Starfish(); var crab = new Crab(SeaCreatureSize.Large); var salmon = new Salmon(SeaCreatureSize.Medium, "brown"); var expectedStarfishJson = "{\r\n \"$concreteType\": \"Spritely.Recipes.Test.JsonConfigurationTest+Starfish, Spritely.Recipes.Test\"\r\n}"; var expectedCrabJson = "{\r\n \"size\": \"large\",\r\n \"$concreteType\": \"Spritely.Recipes.Test.JsonConfigurationTest+Crab, Spritely.Recipes.Test\"\r\n}"; var expectedSalmonJson = "{\r\n \"color\": \"brown\",\r\n \"size\": \"medium\",\r\n \"$concreteType\": \"Spritely.Recipes.Test.JsonConfigurationTest+Salmon, Spritely.Recipes.Test\"\r\n}"; var actualStarfishJson = JsonConvert.SerializeObject(starfish, JsonConfiguration.DefaultSerializerSettings); var actualCrabJson = JsonConvert.SerializeObject(crab, JsonConfiguration.DefaultSerializerSettings); var actualSalmonJson = JsonConvert.SerializeObject(salmon, JsonConfiguration.DefaultSerializerSettings); Assert.That(expectedStarfishJson, Is.EqualTo(actualStarfishJson)); Assert.That(expectedCrabJson, Is.EqualTo(actualCrabJson)); Assert.That(expectedSalmonJson, Is.EqualTo(actualSalmonJson)); }