コード例 #1
0
        public void Berechne_Preise_1__2_erwarte_1_Preis()
        {
            TreeItem treeItem = new TreeItem()
            {
                AktuellerBuchSatz = new List <int>()
                {
                    1
                },
                RestBuecher = new List <int>()
                {
                    2
                },
                BuecherSaetze = new List <TreeItem>()
                {
                    new TreeItem()
                    {
                        AktuellerBuchSatz = new List <int>()
                        {
                            2
                        },
                        RestBuecher   = new List <int>(),
                        BuecherSaetze = new List <TreeItem>()
                    }
                }
            };

            List <double> expected = new List <double>()
            {
                16
            };

            List <double> actual = Algorithmus.Berechne_Preise(treeItem, new List <double>());

            Equalidator.AreEqual(actual, expected);
        }
コード例 #2
0
        public void Network_with_circular_reference()
        {
            var c1 = new Node {
                value = 11
            };
            var c2 = new Node {
                value = 12
            };
            var p = new Node {
                value = 1, left = c1, right = c2
            };

            c2.left = p;

            var c1Tick = new Node {
                value = 11
            };
            var c2Tick = new Node {
                value = 12
            };
            var pTick = new Node {
                value = 1, left = c1Tick, right = c2Tick
            };

            c2Tick.left = pTick;

            Equalidator.AreEqual(p, pTick);
        }
コード例 #3
0
        public void Two_differnet_array_lengths()
        {
            var a = new[] { 1, 2, 3 };
            var b = new[] { 1, 2, 3, 4 };

            Assert.That(() => Equalidator.AreEqual(a, b),
                        Throws.Exception.Message.EqualTo("\nThe length of the structures (including private properties etc.) are different:\n  Expected: 5\n  But was:  6"));
        }
コード例 #4
0
        public void Two_different_structures()
        {
            var a = new { x = 1, y = "2" };
            var b = new { x = 3, y = "2" };

            Assert.That(() => Equalidator.AreEqual(a, b),
                        Throws.Exception.Message.EqualTo("\nThe following values are different:\n  Expected: 1\n  But was:  3"));
        }
コード例 #5
0
        public void Two_differnet_arrays()
        {
            var a = new[] { 1, 2, 3 };
            var b = new[] { 1, 2, 4 };

            Assert.That(() => Equalidator.AreEqual(a, b),
                        Throws.Exception.Message.EqualTo("\nThe following values are different:\n  Expected: 3\n  But was:  4"));
        }
コード例 #6
0
 public void List()
 {
     Equalidator.AreEqual(new List <int> {
         1, 2, 3
     }, new List <int> {
         1, 2, 3
     });
 }
コード例 #7
0
        public void Different_types()
        {
            var a = 1;
            var b = "2";

            Assert.That(() => Equalidator.AreEqual(a, b),
                        Throws.Exception.Message.EqualTo("\nThe following types are different:\n  Expected: System.Int32\n  But was:  System.String"));
        }
コード例 #8
0
 public void Dictionary()
 {
     Equalidator.AreEqual(new Dictionary <string, int> {
         { "a", 1 }, { "b", 2 }
     }, new Dictionary <string, int> {
         { "a", 1 }, { "b", 2 }
     });
 }
コード例 #9
0
        public void IEnumarable_vs_array()
        {
            var ieInt = new List <int> {
                1, 2
            } as IEnumerable <int>;

            Equalidator.AreEqual(new[] { 1, 2 }, ieInt.ToArray());
        }
コード例 #10
0
 public void Compare_simple_structs()
 {
     Equalidator.AreEqual(new SimpleStruct {
         i = 1, s = "a"
     },
                          new SimpleStruct {
         i = 1, s = "a"
     });
 }
コード例 #11
0
        public void Normalize_value_to_invariant()
        {
            var result = HistoricalCsvDataParser.Parse("3,14;a,b");

            Equalidator.AreEqual(new[] {
                new History.Datapoint {
                    Value = 3.14f, Tags = new[] { "a", "b" }
                }
            },
                                 result);
        }
コード例 #12
0
        public void Compare_array_and_list()
        {
            var a = new[] { 42, 99 };
            var l = new List <int>()
            {
                42, 99
            };

            Assert.Throws <NotEqualDueToDifferentStructures>(() => Equalidator.AreEqual(a, l));

            a.ShouldEqual(l, true);
        }
コード例 #13
0
        public void Berechne_Bestpreis_1_2_3_4_5_1_2_3_4_5_3_4_5_erwarte_81_2()
        {
            List <int> buecherListe = new List <int>()
            {
                1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 3, 4, 5
            };

            double expected = 81.2;

            double actual = Algorithmus.Berechne_Bestpreis(buecherListe);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #14
0
        public void Berechne_Bestpreis_1_2_2_erwarte_15_2()
        {
            List <int> buecherListe = new List <int>()
            {
                1, 2, 2
            };

            double expected = 23.2;

            double actual = Algorithmus.Berechne_Bestpreis(buecherListe);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #15
0
        public void Berechne_Bestpreis_1_erwarte_8()
        {
            List <int> buecherListe = new List <int>()
            {
                1
            };

            double expected = 8.0;

            double actual = Algorithmus.Berechne_Bestpreis(buecherListe);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #16
0
 public void Compare_nested_structs()
 {
     Equalidator.AreEqual(new ParentStruct {
         b = true, simple = new SimpleStruct {
             i = 1, s = "a"
         }
     },
                          new ParentStruct {
         b = true, simple = new SimpleStruct {
             i = 1, s = "a"
         }
     });
 }
コード例 #17
0
        public void Berechne_Preis_fuer_Tuple_5_Erwarte_30_0()
        {
            List <int> tuple = new List <int>()
            {
                1, 2, 3, 4, 5
            };

            double expected = 30.0;

            double actual = Algorithmus.Berechne_Preis_fuer_Tuple(tuple);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #18
0
        public void Berechne_Preis_fuer_Tuple_2_Erwarte_15_2()
        {
            List <int> tuple = new List <int>()
            {
                1, 2
            };

            double expected = 15.2;

            double actual = Algorithmus.Berechne_Preis_fuer_Tuple(tuple);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #19
0
        public void Berechne_Preis_fuer_Tuple_4_Erwarte_25_6()
        {
            List <int> tuple = new List <int>()
            {
                1, 2, 3, 4
            };

            double expected = 25.6;

            double actual = Algorithmus.Berechne_Preis_fuer_Tuple(tuple);

            Equalidator.AreEqual(actual, expected);
        }
コード例 #20
0
        public void Type_hierarchy()
        {
            var d1 = new DerivedType(1, 2, 3)
            {
                publicField = 4, publicFieldDerived = 5
            };
            var d2 = new DerivedType(99, 2, 3)
            {
                publicField = 4, publicFieldDerived = 5
            };

            Assert.Throws <NotEqualDueToDifferentValues>(() => Equalidator.AreEqual(d1, d2));
        }
コード例 #21
0
        public void Finde_Tuple_Buecherliste_1_Laenge_5()
        {
            List <int> buecherliste = new List <int>()
            {
                1
            };
            Finde_Tuple_Ergebnis actual   = Algorithmus.Finde_Tuple(buecherliste, 5);
            Finde_Tuple_Ergebnis expected = new Finde_Tuple_Ergebnis(new List <int>()
            {
                1
            }, new List <int>());

            Equalidator.AreEqual(expected, actual);
        }
コード例 #22
0
        public void Write_read()
        {
            const string EVENTFILENAME = "event.txt";

            File.Delete(EVENTFILENAME);
            var sut = new FileStore();

            var e = new RecordedEvent(Guid.NewGuid(), new DateTime(2000, 5, 12, 10, 11, 12), "42", "e", "c", "d1\nd2");

            sut.Write(EVENTFILENAME, e);
            var r = sut.Read(EVENTFILENAME);

            Equalidator.AreEqual(r, e);
        }
コード例 #23
0
        public void Happy_day()
        {
            var result = HistoricalCsvDataParser.Parse("3.14;a,b\n42;c");

            Equalidator.AreEqual(new[] {
                new History.Datapoint {
                    Value = 3.14f, Tags = new[] { "a", "b" }
                },
                new History.Datapoint {
                    Value = 42f, Tags = new[] { "c" }
                }
            },
                                 result);
        }
コード例 #24
0
        public void Berechne_Pfade_1_2_Laenge_5()
        {
            List <int> buecherliste = new List <int>()
            {
                1, 2
            };

            List <TreeItem> actual   = Algorithmus.Berechne_Pfade(buecherliste, 5);
            List <TreeItem> expected = new List <TreeItem>();

            expected.Add(new TreeItem()
            {
                AktuellerBuchSatz = new List <int>()
                {
                    1, 2
                },
                BuecherSaetze = new List <TreeItem>(),
                RestBuecher   = new List <int>()
            });

            expected.Add(new TreeItem()
            {
                AktuellerBuchSatz = new List <int>()
                {
                    1
                },
                RestBuecher = new List <int>()
                {
                    2
                },
                BuecherSaetze = new List <TreeItem>()
                {
                    new TreeItem()
                    {
                        AktuellerBuchSatz = new List <int>()
                        {
                            2
                        },
                        BuecherSaetze = new List <TreeItem>(),
                        RestBuecher   = new List <int>()
                    }
                }
            });

            Equalidator.AreEqual(actual, expected);
        }
コード例 #25
0
        public void Deal_with_whitespace()
        {
            var result = HistoricalCsvDataParser.Parse(" 3.14 ; a , b \r\n\n42;c\n  \n1;d");

            Equalidator.AreEqual(new[] {
                new History.Datapoint {
                    Value = 3.14f, Tags = new[] { "a", "b" }
                },
                new History.Datapoint {
                    Value = 42f, Tags = new[] { "c" }
                },
                new History.Datapoint {
                    Value = 1f, Tags = new[] { "d" }
                },
            },
                                 result);
        }
コード例 #26
0
        public void Deal_with_missing_tags()
        {
            var result = HistoricalCsvDataParser.Parse("1;a\n2;b,\n3;,c\n4;");

            Equalidator.AreEqual(new[] {
                new History.Datapoint {
                    Value = 1f, Tags = new[] { "a" }
                },
                new History.Datapoint {
                    Value = 2f, Tags = new[] { "b" }
                },
                new History.Datapoint {
                    Value = 3f, Tags = new[] { "c" }
                },
                new History.Datapoint {
                    Value = 4f, Tags = new string[0]
                }
            },
                                 result);
        }
コード例 #27
0
        public void Finde_Tuple_Buecherliste_1_2_3_4_5_1_2_3_4_5_1_Laenge_4()
        {
            List <int> buecherliste = new List <int>()
            {
                1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1
            };
            Finde_Tuple_Ergebnis actual   = Algorithmus.Finde_Tuple(buecherliste, 4);
            Finde_Tuple_Ergebnis expected =
                new Finde_Tuple_Ergebnis
                (
                    new List <int>()
            {
                1, 2, 3, 4
            },
                    new List <int>()
            {
                5, 1, 2, 3, 4, 5, 1
            }
                );

            Equalidator.AreEqual(expected, actual);
        }
コード例 #28
0
        public void Hierarchy()
        {
            var c1 = new Node {
                value = 11
            };
            var c2 = new Node {
                value = 12
            };
            var p = new Node {
                value = 1, left = c1, right = c2
            };

            var c1Tick = new Node {
                value = 11
            };
            var c2Tick = new Node {
                value = 12
            };
            var pTick = new Node {
                value = 1, left = c1Tick, right = c2Tick
            };

            Equalidator.AreEqual(p, pTick);
        }
コード例 #29
0
        public void Hierarchy_with_multiple_refs_to_same_object()
        {
            var c1 = new Node {
                value = 11
            };
            var c2 = new Node {
                value = 12, left = c1
            };
            var p = new Node {
                value = 1, left = c1, right = c2
            };

            var c1Tick = new Node {
                value = 11
            };
            var c2Tick = new Node {
                value = 12, left = c1Tick
            };
            var pTick = new Node {
                value = 1, left = c1Tick, right = c2Tick
            };

            Equalidator.AreEqual(p, pTick);
        }
コード例 #30
0
 public void Single_objects()
 {
     Assert.Throws <NotEqualDueToDifferentValues>(() => Equalidator.AreEqual(1, 2));
 }