コード例 #1
0
        public void BasicProcessingOrchestratesFine()
        {
            var lines = new[] { "book1|1.5" };
            var books = new[] { new Book {
                                    Title = "book1", Price = 1.5M
                                } };

            A.CallTo(() => _bookDataProviderFake.GetBookData()).Returns(lines);
            A.CallTo(() => _bookParserFake.Parse(lines)).Returns(books);
            A.CallTo(() => _bookStorageFake.Persist(books)).DoesNothing();

            _bookProcessor.ProcessBooks();

            A.CallTo(() => _bookDataProviderFake.GetBookData()).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _bookParserFake.Parse(lines)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _bookStorageFake.Persist(books)).MustHaveHappened(Repeated.Exactly.Once);
        }
コード例 #2
0
        public void ProcessBooks()
        {
            var bookData = _bookDataProvider.GetBookData();

            var books = _bookParser.Parse(bookData);

            _bookStorage.Persist(books);
        }
コード例 #3
0
        public void BasicParsingWorksFine()
        {
            IEnumerable <string> lines = new[] { "book1|10.1", "book2|20.1" };

            var expected = new[]
            {
                new Book {
                    Title = "book1", Price = 10.1M
                },
                new Book {
                    Title = "book2", Price = 20.1M
                }
            };

            A.CallTo(() => _booksValidatorFake.Validate(A <string[]> ._)).Returns(true);
            A.CallTo(() => _booksMapperFake.Map(A <string[]> ._)).ReturnsNextFromSequence(expected);

            var result = _booksParser.Parse(lines);

            CollectionAssert.AreEqual(expected, result);
        }