public void hoeheIstZuBreit() { Assert.Catch(() => { var x = new Rechteck("Rechteck_1", 1, 1, 1000); }); }
public void CannotCreateRecheckWithEmptyName2() { Assert.Catch(() => { var x = new Rechteck("", 1, 1, 1); }); }
public void hoeheIstNegativ() { Assert.Catch(() => { var x = new Rechteck("Rechteck_1", 1, 1, -1); }); }
public void breiteIstZuLang() { Assert.Catch(() => { var x = new Rechteck("Rechteck_1", 1, 1000, 1); }); }
public void LeangeIstNegativ() { Assert.Catch(() => { var x = new Rechteck("Rechteck_1", -1, 1, 1); }); }
public void DreieckKannErstelltWerden() { var x = new Rechteck("Rechteck_1", 1, 1, 1); Assert.IsTrue(x.nameRechteck != null && x.nameRechteck != ""); Assert.IsTrue(x.laengeRechteck > 0 && x.laengeRechteck < 1000); Assert.IsTrue(x.hoeheRechteck > 0 && x.hoeheRechteck < 1000); Assert.IsTrue(x.breiteRechteck > 0 && x.breiteRechteck < 1000); }
public static void Main(string[] args) { var koerper = new Form[] { new Rechteck("Test_1", 2, 1, 1), new Würfel(1), new Rechteck("Test_2", 2, 1, 1), new Würfel(2), new Rechteck("Test_3", 1, 1, 2), new Würfel(4), new Rechteck("Test_4", 3, 1, 1) }; //------------------------------------------------------------------------------------------------------- Console.WriteLine(JsonConvert.SerializeObject(koerper)); Console.WriteLine(JsonConvert.SerializeObject(koerper, Formatting.Indented)); var settings = new JsonSerializerSettings() { Formatting = Formatting.Indented, TypeNameHandling = TypeNameHandling.Auto }; Console.WriteLine(JsonConvert.SerializeObject(koerper, settings)); var text = JsonConvert.SerializeObject(koerper, settings); var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var filename = Path.Combine(desktop, "items.json"); File.WriteAllText(filename, text); var textFromFile = File.ReadAllText(filename); var itemsFromFile = JsonConvert.DeserializeObject <Form[]>(textFromFile, settings); //----------------------------------------------------------------------------------------------------------------------- var source1 = new Subject <Form>(); source1 .Sample(TimeSpan.FromSeconds(1.0)) .Subscribe(i => Console.WriteLine($"received {i}")) ; var a = new Thread(() => { var i = 0; while (true) { Thread.Sleep(550); var form = new Rechteck("Test", i++, i++, 1); Console.WriteLine("test " + form.breiteRechteck + "test2 " + form.laengeRechteck); } }); a.Start(); //------------------------------------------------------------------------------------------------------------------------- var source = new Subject <Form>(); source .Sample(TimeSpan.FromSeconds(1.0)) .Subscribe(x => Console.WriteLine($"received {x}")) ; var t = new Thread(() => { var i = 0; foreach (var x in koerper) { Thread.Sleep(250); source.OnNext(x); Console.WriteLine($"sent {x}"); i++; } }); t.Start(); //------------------------------------------------------------------------------------------- /* * Console.WriteLine("Länge 1"); * Rechteck ys = new[] Rechteck; * ys = koerper.Where(x => x == 1); * foreach (var y in ys) Console.WriteLine(y); * * * Console.WriteLine("Breite 1"); * ys = koerper.Select(x => x == 1); * foreach (var y in ys) Write(y + " "); WriteLine(); * * var p_rechtecke = new Subject<Rechteck>(); * * p_rechtecke.Subscribe(x => Console.WriteLine($"received value {x}")); * * while (true) * { * System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1)); * p_rechtecke.OnNext("test", 1, 1, 1); // push value i to subscribers * * } */ }