Пример #1
0
        private void ApprovalsVerify <T>(IEnumerable <T> records)
        {
            var serializeObject = JsonConvert.SerializeObject(records, Formatting.Indented);

            Approvals.Verify(new ApprovalTextWriter(serializeObject), new StrategyNamer(_strategy.GetTestType()),
                             new DiffReporter());
        }
            /// <summary>
            /// Moves the engine to the next combination.
            /// </summary>
            /// <returns>True if there was another combination to return, false if no more combinations are available.</returns>
            public bool NextCombination()
            {
                if (this.currentDimensionValues == null)
                {
                    this.currentDimensionValues = new Dictionary <string, object>(this.dimensions.Count);
                    for (int i = 0; i < this.dimensions.Count; i++)
                    {
                        this.currentDimensionIndices[i] = 0;
                    }
                }
                else
                {
                    for (int index = this.currentDimensionIndices.Length - 1; index >= 0; index--)
                    {
                        this.currentDimensionIndices[index]++;
                        if (this.currentDimensionIndices[index] == this.dimensions[index].Values.Count)
                        {
                            this.currentDimensionIndices[index] = 0;
                            if (index == 0)
                            {
#if !SILVERLIGHT
                                string baseline = baselineCallback();
                                if (!skipVerify && !string.IsNullOrEmpty(baseline))
                                {
                                    if (approvalFileSoucePath != null)
                                    {
                                        Approvals.Verify(new ApprovalTextWriter(baseline), new CustomSourcePathNamer(approvalFileSoucePath), Approvals.GetReporter());
                                    }
                                    else
                                    {
                                        Approvals.Verify(baseline);
                                    }
                                }
#endif
                                return(false);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                // Set the parameters
                for (int i = 0; i < this.dimensions.Count; i++)
                {
                    this.currentDimensionValues[this.dimensions[i].Name] = this.dimensions[i].Values[this.currentDimensionIndices[i]];
                }

                return(true);
            }
Пример #3
0
 protected void Approve(string message)
 {
     Approvals.Verify(new ApprovalTextWriter(message), new ConventionTestNamer(GetType().Name),
                      Approvals.GetReporter());
 }