예제 #1
0
        public void Should_UseNumberedModel()
        {
            var fileReader = A.Fake <IFileReader>();

            A
            .CallTo(() => fileReader.Read(null))
            .WithAnyArguments()
            .Returns(new Model()
                     .SetHeader(new[] { "header" })
                     .AddRow(new[] { "one" })
                     .AddRow(new[] { "two" }));

            var formatter = new TableFormatter();
            var output    = A.Fake <IConsole>();

            A
            .CallTo(() => output.Read())
            .Returns('x');

            var coordinator = new DisplayCoordinator(fileReader, formatter, output);

            coordinator.Display("file.csv", 42);

            A
            .CallTo(() => output.Write(A <string> .That.StartsWith("No.|header|"), A <object[]> .Ignored))
            .MustHaveHappened();
        }
예제 #2
0
        public void CanRenderSimpleTable()
        {
            var model = new Model();
              model.SetHeader(new[] { "Foo", "Bar" });
              model.AddRow(new[] { "1", "2" });
              model.AddRow(new[] { "1111", "2222" });

              var output = new TableFormatter().Format(model);

              Assert.AreEqual(@"Foo |Bar |
            ----+----+
            1   |2   |
            1111|2222|
            ", output);
        }
예제 #3
0
        public void CanRenderSimpleTable()
        {
            var model = new Model();

            model.SetHeader(new[] { "Foo", "Bar" });
            model.AddRow(new[] { "1", "2" });
            model.AddRow(new[] { "1111", "2222" });

            var output = new TableFormatter().Format(model);

            Assert.AreEqual(@"Foo |Bar |
----+----+
1   |2   |
1111|2222|
", output);
        }
예제 #4
0
        public void CanRenderPagedTable_Page1()
        {
            var model = new Model();
              model.SetHeader(new[] { "Foo", "Bar" });
              model.AddRow(new[] { "1", "2" });
              model.AddRow(new[] { "1111", "2222" });

              var page1 = new PagedModel(model, 1, 1);

              var output = new TableFormatter().Format(page1);

              Assert.AreEqual(@"Foo |Bar |
            ----+----+
            1111|2222|
            ", output);
        }
예제 #5
0
        public void CanRenderPagedTable_Page1()
        {
            var model = new Model();

            model.SetHeader(new[] { "Foo", "Bar" });
            model.AddRow(new[] { "1", "2" });
            model.AddRow(new[] { "1111", "2222" });

            var page1 = new PagedModel(model, 1, 1);

            var output = new TableFormatter().Format(page1);

            Assert.AreEqual(@"Foo |Bar |
----+----+
1111|2222|
", output);
        }
        public void Should_UseNumberedModel()
        {
            var fileReader = A.Fake<IFileReader>();
              A
            .CallTo(() => fileReader.Read(null))
            .WithAnyArguments()
            .Returns(new Model()
                   .SetHeader(new[] { "header" })
                   .AddRow(new[] { "one" })
                   .AddRow(new[] { "two" }));

              var formatter = new TableFormatter();
              var output = A.Fake<IConsole>();
              A
            .CallTo(() => output.Read())
            .Returns('x');

              var coordinator = new DisplayCoordinator(fileReader, formatter, output);

              coordinator.Display("file.csv", 42);

              A
            .CallTo(() => output.Write(A<string>.That.StartsWith("No.|header|"), A<object[]>.Ignored))
            .MustHaveHappened();
        }