Ejemplo n.º 1
0
        public When_merge_a_document()
        {
            repository = Substitute.For<IPersonRepository>();
            printer = Substitute.For<IDocumentPrinter>();
            tool = new MailMerge(repository, printer);

            Document document = new Document {TokenizedDocument = Resources.TestDocument};
            tool.MergeAndPrint(document);
        }
        public When_merge_a_document()
        {
            // Arrangement
            persons = new Fixture().CreateMany<Person>(5).ToArray();

            repository = Substitute.For<IPersonRepository>();
            repository.Persons(Resources.TestCustomer).Returns(persons);

            printer = Substitute.For<IDocumentPrinter>();
            printer.When(p => p.Print(Arg.Any<MergedDocument>())).Do(call =>
            {
                receivedPersons.Add(call.Arg<MergedDocument>().Person);
                receivedDocuments.Add(call.Arg<MergedDocument>().Document);
            });

            tool = new MailMerge(repository, printer);

            document = new Document {TokenizedDocument = Resources.TestDocument};

            // Act
            tool.MergeAndPrint(Resources.TestCustomer, document);
        }