Exemple #1
0
            public void Combine_ForLength3FromBinaryValues_Success()
            {
                var k        = 3;
                var n        = 1; //0, 1
                var testable = new _2_1_1();
                var expected = new[] { "000", "001", "010", "011", "100", "101", "110", "111" };

                var result = testable.Run(k, n);

                Assert.That(result.Select(x => string.Join("", x)).ToArray(), Is.EquivalentTo(expected));
            }
Exemple #2
0
            public void PropertyCombine_AnyInputValues_FirstAndLastValuesAreCorrect()
            {
                var testable = new _2_1_1();

                Prop.ForAll <int, int>(Arb.From <int>().Filter(x => x > 0 && x < 5), Arb.From <int>().Filter(x => x > 0 && x < 10),
                                       (k, n) =>
                {
                    var init = Enumerable.Range(0, k).Select(x => 0).ToArray();
                    var last = Enumerable.Range(0, k).Select(x => n).ToArray();

                    var result = testable.Run(k, n);

                    Assert.That(result.First().SequenceEqual(init));
                    Assert.That(result.Last().SequenceEqual(last));
                }).QuickCheckThrowOnFailure();
            }
Exemple #3
0
            public void PropertyCombine_AnyInputValues_AnalogAndMainSolutionShouldBeEqual()
            {
                var testable = new _2_1_1();

                Prop.ForAll(Arb.From <int>().Filter(x => x > 0 && x < 5), Arb.From <int>().Filter(x => x > 0 && x < 10),
                            (k, n) =>
                {
                    var result       = testable.Run(k, n).Select(x => x.ToList()).ToList();
                    var analogResult = testable.SimpleAnalog(k, n);

                    for (var i = 0; i < result.Count; i++)
                    {
                        Assert.That(result[i].SequenceEqual(analogResult[i]));
                    }
                }).QuickCheckThrowOnFailure();
            }