Ejemplo n.º 1
0
            public void GeneratingContentFromStringTemplateSetsContent()
            {
                // Given
                IDocument    document = Substitute.For <IDocument>();
                MemoryStream stream   = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty));

                document.GetStream().Returns(stream);
                IModule           generateContent = new GenerateContent(@"[rs:4;,\s]{<noun>}").WithSeed(1000);
                IExecutionContext context         = Substitute.For <IExecutionContext>();
                object            result;

                context.TryConvert(new object(), out result)
                .ReturnsForAnyArgs(x =>
                {
                    x[1] = x[0];
                    return(true);
                });

                // When
                generateContent.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list

                // Then
                context.Received(1).GetDocument(Arg.Any <IDocument>(), Arg.Any <string>());
                context.Received().GetDocument(Arg.Is(document), "nectarine, gambler, marijuana, chickadee");
                stream.Dispose();
            }
Ejemplo n.º 2
0
            public void GeneratingContentFromStringTemplateSetsContent()
            {
                // Given
                TestExecutionContext context  = new TestExecutionContext();
                TestDocument         document = new TestDocument();
                IModule generateContent       = new GenerateContent(@"[rs:4;,\s]{<noun>}").WithSeed(1000);

                // When
                IList <IDocument> results = generateContent.Execute(new[] { document }, context).ToList(); // Make sure to materialize the result list

                // Then
                Assert.That(results.Select(x => x.Content), Is.EquivalentTo(new[] { "nectarine, gambler, marijuana, chickadee" }));
            }
Ejemplo n.º 3
0
            public void GeneratingContentFromStringTemplateSetsContent()
            {
                // Given
                IDocument document = Substitute.For<IDocument>();
                MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty));
                document.GetStream().Returns(stream);
                IModule generateContent = new GenerateContent(@"[rs:4;,\s]{<noun>}").WithSeed(1000);
                IExecutionContext context = Substitute.For<IExecutionContext>();
                object result;
                context.TryConvert(new object(), out result)
                    .ReturnsForAnyArgs(x =>
                    {
                        x[1] = x[0];
                        return true;
                    });

                // When
                generateContent.Execute(new[] {document}, context).ToList(); // Make sure to materialize the result list

                // Then
                context.Received(1).GetDocument(Arg.Any<IDocument>(), Arg.Any<string>());
                context.Received().GetDocument(Arg.Is(document), "nectarine, gambler, marijuana, chickadee");
                stream.Dispose();
            }