Esempio n. 1
0
        public void WhenCreateViewModelThenVerifyGetAllLevels()
        {
            this.controller.Setup(x => x.GetAllLevels()).Returns(new List <int> {
                1, 2, 3
            });
            var viewModel = new MatchConfigViewModel(this.controller.Object);

            this.controller.Verify(x => x.GetAllLevels(), Times.Once, "GetAllLevels was not called");
            Approvals.VerifyAll(viewModel.Levels, "Level");
        }
        public void OfClassType()
        {
            var(propertyValuesFromType, fieldValuesFromType) = Creator.GetPropertyAndFieldValues(typeof(AnotherClass), null);

            var valueStrings = propertyValuesFromType.Select(kvp => $"{kvp.Key} => {kvp.Value}").ToList();

            valueStrings.AddRange(fieldValuesFromType.Select(kvp => $"{kvp.Key} => {kvp.Value}"));

            Approvals.VerifyAll(valueStrings, "results");
        }
Esempio n. 3
0
        public void TestPdf_Replacements()
        {
            var pdfOriginal = PathUtilities.GetAdjacentFile("sample.pdf");

            using (var fileStream = File.Open(pdfOriginal, FileMode.Open))
            {
                var replacements = PdfScrubber.FindReplacements(fileStream);
                Approvals.VerifyAll("Replacements", replacements, r => r.ToString());
            }
        }
Esempio n. 4
0
        public void WhenCreateViewModelThenVerifyGetAllOpponents()
        {
            this.controller.Setup(x => x.GetAllOpponents()).Returns(new List <string> {
                "Opponent1", "Opponent2", "Opponent3"
            });
            var viewModel = new MatchConfigViewModel(this.controller.Object);

            this.controller.Verify(x => x.GetAllOpponents(), Times.Once, "GetAllOpponents was not called");
            Approvals.VerifyAll(viewModel.Opponents, "Opponent");
        }
        public void ControlWithLocalAndBaseKeys()
        {
            var checkBox = new CheckBox();

            checkBox.CheckedChanged += TestingListener.AnotherStandardCallback;
            checkBox.Click          += TestingListener.AnotherStandardCallback;
            checkBox.Click          += TestingListener.StandardCallback;

            Approvals.VerifyAll(checkBox.GetEventHandlerListEvents(), string.Empty);
        }
Esempio n. 6
0
        public void TestPdf_ScrubberForITextVersion()
        {
            var cases = new[]
            {
                "xxxxiText-7.1.11 for .NETxxxx",
                "xxxxiText® 7.1.11 ©2000-2020xxxx",
            };

            Approvals.VerifyAll("IText Version", cases, c => $@"{PdfScrubber.FindITextVersion(c).ToList().ToReadableString()} For {c}");
        }
Esempio n. 7
0
        public void TestStripComments()
        {
            string[] lines =
            {
                "line which has no comment", "--line which is nothing but comment",
                "a line which has stuff --at the front"
            };

            Approvals.VerifyAll(lines.StripSingleLineComments(), "nocomments");
        }
Esempio n. 8
0
    static void VerifyDirectory(string targetDirectory)
    {
        var files = Directory.EnumerateFiles(targetDirectory, "*.*");

        var dictionary = files.ToDictionary(
            keySelector: x => Path.GetFileName(x),
            elementSelector: x => $"\r\n{File.ReadAllText(x)}\r\n\r\n");

        Approvals.VerifyAll(dictionary);
    }
 public void FindAbandonedApprovalFiles()
 {
     using (var t = new TempFile(PathUtilities.GetAdjacentFile("DeletedClass.AbandoneMethod.approved.txt")))
     {
         t.WriteAllText("Llewellyn was here");
         var path = PathUtilities.GetDirectoryForCaller();
         var list = ApprovalMaintenance.FindAbandonedFiles(path);
         Approvals.VerifyAll("Abandoned Files:", list, f => f.Name);
     }
 }
Esempio n. 10
0
        public void Test_CreateGAFRecordsForDocumentGroup_For_Documents_With_Two_Taxes_And_Custom_LineNumbers(string module)
        {
            //Arrange
            var taxDataItems = TaxDataBuilder.CreateTaxDataItems(new[]
            {
                TaxDataContext.VatTax.TaxID,
                TaxDataContext.VatTax2.TaxID
            });

            var taxAgencyID = VendorDataContext.TaxAgency.BAccountID;
            var taxPeriodID = TaxPeriodDataContext.TaxPeriod.TaxPeriodID;

            var billAggr1 = new APInvoiceAggregateBuilder()
                            .CreateDocument(
                APDocType.Invoice,
                refNbr: "DOC001",
                docDate: new DateTime(2015, 3, 1),
                curyID: "EUR",
                module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor.BAccountID,
                                          vendorLocationID: LocationDataContext.VendorLocation.LocationID)
                            .AddTran(100, 200, "tyre purchase 1", lineNbr: 3, taxDataItems: taxDataItems)
                            .AddTran(300, 600, "oil purchase 1", lineNbr: 7, taxDataItems: taxDataItems)
                            .Build();

            var billAggr2 = new APInvoiceAggregateBuilder()
                            .CreateDocument(APDocType.Invoice,
                                            refNbr: "DOC002",
                                            docDate: new DateTime(2015, 3, 5),
                                            curyID: "GBP",
                                            module: module)
                            .DocumentWith(vendorID: VendorDataContext.Vendor2.BAccountID,
                                          vendorLocationID: LocationDataContext.Vendor2Location.LocationID)
                            .AddTran(200, 400, "tyre purchase 2", lineNbr: 4, taxDataItems: taxDataItems)
                            .AddTran(500, 700, "oil purchase 2", lineNbr: 9, taxDataItems: taxDataItems)
                            .Build();

            var billAggregs = new[] { billAggr1, billAggr2 };

            SetupRepositoryMethods(billAggregs, billAggr1.Document.OrigModule, billAggr1.Document.DocType, taxAgencyID, taxPeriodID);

            var documentGroup = new DocumentGroup <AP.APInvoice>()
            {
                Module            = billAggr1.Document.OrigModule,
                DocumentType      = billAggr1.Document.DocType,
                DocumentsByRefNbr = billAggregs.ToDictionary(aggr => aggr.Document.RefNbr, aggr => aggr.Document)
            };

            //Action
            var purchaseRecords = InvoiceGafRecordsCreator.CreateGAFRecordsForDocumentGroup(documentGroup, taxAgencyID,
                                                                                            taxPeriodID);

            //Assert
            Approvals.VerifyAll(purchaseRecords, "purchaseRecords", record => record.Dump());
        }
Esempio n. 11
0
        public void GivenBusinessLogicBehaviourGenerator_WhenSingleNotSupportRegen_ThenSingleClassCreated()
        {
            var settings = Substitute.For <ISettings>();
            var module   = ModuleBuilders.CreateModule();

            var c = new BusinessLogicBehaviour.Generator(settings, module, module.Models.First());

            IFileGroup output = c.Create() as IFileGroup;

            Approvals.VerifyAll(output.Files, "file", f => $"{f.FullName}\r\n{f.Content}");
        }
Esempio n. 12
0
        public void show_percentage_correctly()
        {
            var console = new MockConsole(80, 60);

            for (int i = 1; i < 21; i++)
            {
                var pb1 = new ProgressBarSlim(20, console);
                pb1.Refresh(i, "cats");
            }
            Approvals.VerifyAll(console.BufferWritten, "");
        }
Esempio n. 13
0
        public void percentage_should_be_shown_correctly()
        {
            var console = new MockConsole(80, 60);

            for (int i = 1; i < 21; i++)
            {
                var pb1 = new ProgressBar(console, PbStyle.DoubleLine, 20);
                pb1.Refresh(i, "cats");
            }
            Approvals.VerifyAll(console.BufferWritten, "");
        }
Esempio n. 14
0
 public void VerifyAddition()
 {
     // Push 2
     Program.HandleOneUserInput("2");
     // Push 4
     Program.HandleOneUserInput("4");
     // Push + operation
     Program.HandleOneUserInput("+");
     // Verify stack contains 6
     Approvals.VerifyAll("Stack", Program.StackContents, value => value.ToString());
 }
Esempio n. 15
0
 public void TestNotifySellerThatTheItemSold()
 {
     //create auction world
     //start an auction
     //bob bids $5
     //verify closing notification emails
     (Users users, User scott, User bob, Auction auction) = AuctionTests.CreateAuctionWorld();
     auction.StartAuction();
     auction.Bid(bob, 5);
     Approvals.VerifyAll(auction.GetClosingEmailNotifications());
 }
Esempio n. 16
0
        public void OnlyReportFailingTypesIfMixed()
        {
            var ctors = new Dictionary <Type, Func <object> >
            {
                { typeof(NonDefaultConstructor), () => new NonDefaultConstructor(44) }
            };
            var results         = FindSiblingsThatAreMissingStructural.Equality <BadEqualityClass>(null, ctors);
            var friendlyResults = results.Select(t => t.ToString()).OrderBy(t => t);

            Approvals.VerifyAll(friendlyResults, "Bad Equality");
        }
Esempio n. 17
0
        public void GivenAlarmsInMultipleModuleHistories_WhenGetHistoricAlarmsOfBothModules_ThenReturnAllAlarms()
        {
            _labelModule1.SetupHistoricAlarms(LabelModuleAlarm(15));
            _loadingStation1.SetupHistoricAlarms(LoadingStationAlarm(3), LoadingStationAlarm(23));
            IAlarmManagementService service = CreateService();
            Dictionary <string, List <AlarmDTO> > alarms = service.GetHistoricAlarmsOfModules(new Collection <string> {
                LAB_1(), LOA_1()
            });

            Approvals.VerifyAll(alarms, x => x.ToJson());
        }
        public void TestIsImage()
        {
            var files = new[]
            {
                "image.png", "image.gif", "image.jpg", "image.jpeg", "image.tif", "image.tiff",
                "movie.avi", "text.txt", "excel.xls"
            };

            Approvals.VerifyAll(
                files,
                f => $"{f}  => {TortoiseImageDiffReporter.INSTANCE.IsWorkingInThisEnvironment(f)}");
        }
Esempio n. 19
0
        public void GetComicsForCharacterTest()
        {
            // Arrange
            var characterId = 1009268;

            // Act
            var comics = _marvel.GetComicsForCharacter(characterId);

            // Assert
            Assert.IsInstanceOfType(comics, typeof(IEnumerable <Comic>));
            Approvals.VerifyAll(comics.Select(comic => JsonConvert.SerializeObject(comic)), "Comics");
        }
        public void ReturnCustomersFullNameInAlphabeticalOrder()
        {
            var vipCustomers = new VipCustomers();

            vipCustomers.Add(new Customer("Mandy", "Harris"));
            vipCustomers.Add(new Customer("John", "Smith"));
            vipCustomers.Add(new Customer("Albert", "Thomson"));

            var orderedVipCustomers = vipCustomers.InAlphabeticalOrder();

            Approvals.VerifyAll(orderedVipCustomers, "");
        }
Esempio n. 21
0
        public void TestCollectBoundies()
        {
            var text = @"Content-Type: multipart/mixed; boundary=--boundary_1_f3c617c1-4388-492c-8e07-0ef9bdb8af93


----boundary_1_f3c617c1-4388-492c-8e07-0ef9bdb8af93
Content-Type: multipart/alternative; boundary=--boundary_0_283b02d8-4af3-4d14-83bd-6d7181499f83

";

            Approvals.VerifyAll(EmailApprovals.FindBoundaries(text), "boundry");
        }
Esempio n. 22
0
        public void access_to_all_content()
        {
            var responses = controller.Contents.Select(c => controller.Post(new AccessRequest {
                SecurityToken = c.SecurityToken.ToMars(), ApiKey = DbProxyController.apiKey.ToMars()
            })).ToList();

            foreach (var response in responses)
            {
                Assert.IsNull(response.ErrorMessage);
            }
            Approvals.VerifyAll(responses.Select(r => r.NextSecurityLevelChallenge), "responseNextChallenge");
        }
        public void ApprovalsArray()
        {
            // assign
            var p = Student.Default();

            // act

            // assert... old way
            string pSerialized = JsonConvert.SerializeObject(p, Formatting.Indented);

            Approvals.VerifyAll(p.SchoolHistory.Select(c => c.Name), "Schlool");
        }
Esempio n. 24
0
        public void GeneratorPopulatesPeopleList2()
        {
            var viewModel  = new ListViewModel();
            var attachment = new ListGeneratorAttachment();

            // Initialize data generator
            Randomizer.Seed = new Random(12345);

            AttachmentHelper.Attach(attachment, viewModel);

            Approvals.VerifyAll(viewModel.People, "People", p => $"{p.FirstName} {p.LastName} {p.Address} {p.PhoneNumber}");
        }
Esempio n. 25
0
        public void GivenAlarmsInLoa1AndLab1_WhenGetCurrentAlarmsOfBothModules_ThenReturnAlarmsOfBothModules()
        {
            IAlarmManagementService service = CreateService();

            _loadingStation1.SetupCurrentAlarms(LoadingStationAlarm(1));
            _labelModule1.SetupCurrentAlarms(LabelModuleAlarm(2));
            Dictionary <string, List <AlarmDTO> > alarms = service.GetCurrentAlarmsOfModules(new Collection <string> {
                LAB_1(), LOA_1()
            });

            Approvals.VerifyAll(alarms, x => x.ToJson());
        }
Esempio n. 26
0
        public void GivenDataAccessConfigGenerator_WhenSingleSupportRegen_ThenSingleClassCreated()
        {
            var settings = Substitute.For <ISettings>();

            settings.SupportRegen = true;
            var module = ModuleBuilders.CreateModule();

            var c = new EntityFrameworkClass.Generator(settings, module, module.Models.First());

            IFileGroup output = c.Create() as IFileGroup;

            Approvals.VerifyAll(output.Files, "file", f => $"{f.FullName}\r\n{f.Content}");
        }
Esempio n. 27
0
        public void ApprovalHelpShowWhenThingsHaveBeenAdded()
        {
            var punch = new Dictionary <string, string>();

            punch["Orange Juice"] = "2 cups";
            punch["Lime Juice"]   = "1/2 cup";
            punch["Fruit Juice"]  = "1 cup";
            punch["Strawberries"] = "20";
            punch["Mint leaves"]  = "3";
            punch["Sprite"]       = "2 cups";
            //punch[___] = ___; // <-- Uncomment Line to solve
            Approvals.VerifyAll(punch);
        }
Esempio n. 28
0
        public void ApprovalHelpShowWhenThingsHaveBeenRemoved()
        {
            var m = new Dictionary <string, string>();

            m["Miss Scarlet"]    = "Conservitory";
            m["Colonel Mustard"] = "Kitchen";
            m["Mrs. White"]      = "Billiard Room";
            m["Mr. Green"]       = "Library";
            m["Mrs. Peacock"]    = "Dining Room";
            m["Professor Plum"]  = "Study";
            m.Remove(___);
            Approvals.VerifyAll(m);
        }
Esempio n. 29
0
        public void DictionariesAreSortedBeforeDisplay()
        {
            var m = new Dictionary <int, string>();

            m[1000] = "M";
            m[10]   = "X";
            m[1]    = "I";
            m[100]  = "C";
            m[5]    = "V";
            m[500]  = "D";
            m[50]   = ___;
            Approvals.VerifyAll(m);
        }
        public void SendAll()
        {
            var input  = new InputPipe <int>("input");
            var middle = input.Process(p => p + 1);
            var end    = middle.Process(p => p.ToString()).Collect();

            var inputsAndOutputs = middle.GetInputs <int>().AndOutputs <string>();

            var(inputPipe, collectorPipe) = inputsAndOutputs.AsTuple();

            inputsAndOutputs.SendAll(new[] { 1, 2, 3 });
            Approvals.VerifyAll(inputsAndOutputs.Output1.Results, "");
        }