public void Test()
        {
            var sut     = new MyClass();
            var firsts  = new[] { -10, -5, 0, 5, 10 };
            var seconds = new[] { -2, -1, 0, 1, 2 };
            var logs    = new[] {
                CreateMockLog("mock log")
            };
            var webServices = new[] {
                CreateMockWebServiceReturn("-10"),
                CreateMockWebServiceReturn("0"),
                CreateMockWebServiceReturn("10"),
                CreateMockWebServiceReturn("something unexpected"),
                CreateMockWebServiceReturn(null),
                CreateMockWebServiceException("some exception")
            };

            // Act and assert
            StringWriter stringWriter;

            Reset(out stringWriter);
            Func <object, string> formatter = (result) => result + "\r\n===== Mock Log =====\r\n" + stringWriter.ToString() + Reset(out stringWriter);

            CombinationApprovals.VerifyAllCombinations(sut.DoWeirdMath, formatter, firsts, seconds, logs, webServices);
        }
Exemplo n.º 2
0
 public void DadoQueAtualizaQualidade()
 {
     CombinationApprovals.VerifyAllCombinations(AtualizarQualidade,
                                                new String[] { "foo", "Queijo Brie Envelhecido", "Ingressos para o concerto do Turisas", "Dente do Tarrasque", "Bolo de Mana Conjurado" },
                                                new int[] { -1, 0, 2, 6, 11 },
                                                new int[] { 0, 1, 49, 50 });
 }
Exemplo n.º 3
0
 public void CombinatorialApprovals()
 {
     CombinationApprovals.VerifyAllCombinations(
         (a, b) => a + b,
         new[] { 1, 2, 3 },
         new[] { 0, -1, -5 });
 }
Exemplo n.º 4
0
 public void CharacterizationTest()
 {
     string[] names    = { "foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros" };
     int[]    sellIns  = { -1, 0, 1, 2, 5, 6, 7, 10, 11, 12, 49, 50, 51 };
     int[]    qualitys = { -1, 0, 1, 2, 49, 50, 51 };
     CombinationApprovals.VerifyAllCombinations(GetItem, names, sellIns, qualitys);
 }
Exemplo n.º 5
0
        public void TwoDimensionalInputGoesByTheSquare()
        {
            int[] small = { 1, 2, 3 };
            int[] big   = { 11, ____, 55 };

            CombinationApprovals.VerifyAllCombinations((a, b) => a * b, small, big);
        }
Exemplo n.º 6
0
        public void ReturnAllPosibilites()
        {
            string[] name    = { "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros", "varita1" };
            int[]    sellIn  = { -32, -14, -9, -1, 0, 1, 3, 5, 6, 7, 10, 11, 12, 49, 50, 52, 60, 78, 89, 120 };
            int[]    quality = { -32, -14, -9, -1, 0, 1, 2, 3, 4, 23, 35, 48, 49, 50, 51, 53, 74, 78, 89, 120 };

            CombinationApprovals.VerifyAllCombinations(UpdateQuality, name, sellIn, quality);
        }
Exemplo n.º 7
0
 public void CombinationTest()
 {
     CombinationApprovals.VerifyAllCombinations(
         ParameterizedTest,
         new[] { 1, 2, 3, 4 },
         new[] { 2, 3, 4 },
         new[] { 3, 4, 5 });
 }
Exemplo n.º 8
0
 public void get_same_results_with_incremental_values_and_wrong_matchs()
 {
     CombinationApprovals.VerifyAllCombinations(
         ExecuteTriviaGameWithIncrementalValues
         , new List <int> {
         0
     });
 }
Exemplo n.º 9
0
 public void TestExceptions()
 {
     // The devide by zero exception has a different message in Mono.
     using (ApprovalTests.Namers.ApprovalResults.UniqueForOs()) {
         int[] n = { 0, 2 };
         CombinationApprovals.VerifyAllCombinations((a, b) => a / b, n, n);
     }
 }
Exemplo n.º 10
0
        public void ExceptionsAreOk()
        {
            int[] numerator    = { 60, 126, 42 };
            int[] denominator1 = { 3, 2 };
            int[] denominator2 = { -1, ____, 1 };

            CombinationApprovals.VerifyAllCombinations((a, b, c) => a / (b + c), numerator, denominator1, denominator2);
        }
Exemplo n.º 11
0
 private void CreateMessageAndTest()
 {
     CombinationApprovals.VerifyAllCombinations(
         (name, type, newRate) => printer.PrintObject(messager.CreateMessage(name, type, newRate)),
         new[] { "Olga", "Evgeniy" },
         new[] { AccountType.Cheque, AccountType.Credit, AccountType.Savings },
         new[] { 0.1m, 0.01m, 0.2m });
 }
 public void Test1()
 {
     CombinationApprovals.VerifyAllCombinations(
         DoQualityUpdate,
         new[] { "foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros" },
         new[] { -1, 0, 2, 6, 11, },
         new[] { 0, 1, 49, 50 });
 }
 public void TestExceptions()
 {
     using (Namers.ApprovalResults.UniqueForOs())
     {
         int[] n = { 0, 2 };
         CombinationApprovals.VerifyAllCombinations((a, b) => a / b, n, n);
     }
 }
 public void AllItemCombinations()
 {
     CombinationApprovals.VerifyAllCombinations(
         DoUpdateQuality,
         new string[] { "foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros" },
         new int[] { -1, 0, 5, 10, 11 },     // SellIn
         new int[] { 0, 1, 49, 50 }          // Quality
         );
 }
 public static void VerifyAllCombinations <T1, T2, T3, T4, T5, T6, TResult>(
     Func <T1, T2, T3, T4, T5, T6, TResult> processCall,
     IEnumerable <T1> aList, IEnumerable <T2> bList, IEnumerable <T3> cList, IEnumerable <T4> dList,
     IEnumerable <T5> eList,
     IEnumerable <T6> fList)
 {
     CombinationApprovals.VerifyAllCombinations((a, b, c, d, e, f) => processCall(a, b, c, d, e, f), aList, bList,
                                                cList, dList, eList, fList);
 }
Exemplo n.º 16
0
 public void SwitchStore()
 {
     CombinationApprovals.VerifyAllCombinations(DoSwitchStore,
                                                new[] { "HOME_DELIVERY", "PICKUP", "SHIPPING", null },
                                                new[] { "NEARBY", "NOT_NEARBY", null },
                                                new[] { _backaplan, null },
                                                new[] { true, false },
                                                new[] { true, false });
 }
Exemplo n.º 17
0
        public void WorkingWithALambda()
        {
            var newMillenium = new DateTime(2000, 1, 1, 0, 0, 0);

            string[] years  = { "yy", "yyyy" };
            string[] months = { "M", "MMM", "MMMM" };
            string[] days   = { "dd", "dddd" };

            CombinationApprovals.VerifyAllCombinations((y, m, d) => newMillenium.ToString(y + "/" + ___ + "/" + d), years, months, days);
        }
Exemplo n.º 18
0
        public void ParseExampleAddresses()
        {
            string[] examples  = { "9999 ATLANTIC AVE BROOKLYN, N.Y. 99999", "P.O.Box 9999, Brea, CA 99999" };
            bool[]   normalize = { true, false };

            CombinationApprovals.VerifyAllCombinations(
                Parser.ParseAddress,
                x => Environment.NewLine + ((AddressParseResult)x).WritePropertiesToString(),
                examples,
                normalize);
        }
Exemplo n.º 19
0
 public void ApproveGildedRose()
 {
     string[] names     = { "foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros" };
     int[]    sellins   = { -1, 0, 12, 6, 2 };
     int[]    qualities = { 0, 1, 48, 49, 50 };
     CombinationApprovals.VerifyAllCombinations(
         UpdateItems,
         names,
         sellins,
         qualities);
 }
Exemplo n.º 20
0
        public void CreateAllMessages(bool useRefactored)
        {
            var createMessage = GetCreateMessage(useRefactored);

            CombinationApprovals.VerifyAllCombinations(
                (customerName, accountType, rate) =>
                createMessage(customerName, accountType, rate),
                ApprovalTestsExtensions.Print,
                new[] { "Jack", "Lily" },
                new[] { AccountType.Cheque, AccountType.Credit, AccountType.Savings },
                new[] { 0.05m, 0.1m });
        }
Exemplo n.º 21
0
        public void ApproveMessager()
        {
            var st = new Stateprinter();

            st.Configuration.Add(new SbValueConverter());
            var messager = new NewRateEmailMessager();

            CombinationApprovals.VerifyAllCombinations(
                (name, aType, rate) => messager.CreateMessage(name, aType, rate), x => st.PrintObject(x),
                new[] { "Vladimir Putin" },
                new[] { AccountType.Cheque, AccountType.Credit, AccountType.Savings },
                new[] { 0.05m, 2, 10, 100, 150, -100 });
        }
Exemplo n.º 22
0
        public void ParseExampleAddresses()
        {
            var text     = File.ReadAllText(PathUtilities.GetAdjacentFile("samples.txt"));
            var examples = text.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries)
                           .Where(s => !s.StartsWith("#", StringComparison.OrdinalIgnoreCase));

            bool[] normalize = { true, false };

            CombinationApprovals.VerifyAllCombinations(
                Parser.ParseAddress,
                x => Environment.NewLine + ((AddressParseResult)x).WritePropertiesToString(),
                examples,
                normalize);
        }
Exemplo n.º 23
0
        public void get_same_results_with_same_entries_and_wrong_answers()
        {
            var diceValues = new List <int>()
            {
                6
            };
            var successValues = new List <int>()
            {
                6
            };

            CombinationApprovals.VerifyAllCombinations(
                ExecuteTriviaGameWithWrongAnswers,
                diceValues,
                successValues);
        }
Exemplo n.º 24
0
        public void DescribeTriviaGame()
        {
            var seedsOne = new[] { 1, 21, 311, 141, 2225, 6 };
            var seedsTwo = new[] { 17, 19, 29, 37, 41, 57, 67 };

            CombinationApprovals.VerifyAllCombinations(
                (seedOne, seedTwo) =>
            {
                _console = new TestableConsole();
                GameRunner.RunGame(
                    new Random(seedOne * seedTwo + seedTwo),
                    _console.WriteLine);
                return(_console.ToString());
            },
                seedsOne,
                seedsTwo);
        }
Exemplo n.º 25
0
 public void updateQuality()
 {
     CombinationApprovals.VerifyAllCombinations
     (
         doUpdateQuality,
         new string[]
     {
         "+5 Dexterity Vest",
         "Aged Brie",
         "Elixir of the Mongoose",
         "Sulfuras, Hand of Ragnaros",
         "Backstage passes to a TAFKAL80ETC concert",
         "Conjured Mana Cake"
     },
         new int[] { -1, 1, 0, 6, 11 },
         new int[] { 0, 10, 50 }
     );
 }
Exemplo n.º 26
0
        public void ApprovalTests()
        {
            IEnumerable <string> names = new[]
            {
                "other",
                "Aged Brie",
                "Backstage passes to a TAFKAL80ETC concert",
                "Sulfuras, Hand of Ragnaros"
            };
            IEnumerable <int> sellIns   = Enumerable.Range(-5, 30);
            IEnumerable <int> qualities = Enumerable.Range(-5, 60);

            CombinationApprovals.VerifyAllCombinations(
                (name, sellIn, quality) =>
                GildedRose.UpdateQuality(new Item {
                Name = name, SellIn = sellIn, Quality = quality
            }),
                names, sellIns, qualities);
        }
Exemplo n.º 27
0
        public void DoSomething_WhenSomething()
        {
            var serverData = new ProviderData();

            serverData.Timestamp = DateTime.Parse("01.01.01");
            serverData.Products  = new[] { new ProductData()
                                           {
                                               Id = new Guid(), MeasureUnitCode = "", Name = "", Price = 10
                                           } };
            CombinationApprovals.VerifyAllCombinations(
                Verify,
                new string[] { measurecode },
                new string[] { productName },
                new decimal[] { 10 },
                new ProviderData[] { null, data, serverData },
                new int?[] { null, 11 },
                new MeasureUnit[] { new MeasureUnit(), null },
                new DateTime[] { DateTime.MinValue, DateTime.MaxValue, DateTime.Parse("01.01.01"), }
                );
        }
Exemplo n.º 28
0
        public void UpdateQuality()
        {
            var name = new List <string>()
            {
                "foo", "Aged Brie", "Backstage passes to a TAFKAL80ETC concert", "Sulfuras, Hand of Ragnaros"
            };
            var sellIn = new List <int>()
            {
                -1, 0, 2, 6, 11
            };
            var quality = new List <int>()
            {
                0, 49, 50
            };

            CombinationApprovals.VerifyAllCombinations(
                ExecuteUpdateQuality,
                name,
                sellIn,
                quality);
        }
Exemplo n.º 29
0
 public void OneDimensionalInputIsTheSameAsArray()
 {
     string[] letters = { "a", "b", "c", ___, "e" };
     CombinationApprovals.VerifyAllCombinations(a => a, letters);
 }
Exemplo n.º 30
0
 public void TestLockDown2()
 {
     int[] n = { 1, 2 };
     CombinationApprovals.VerifyAllCombinations((a, b) => Echo(a, b), n, n);
 }