コード例 #1
0
        public void ShouldReturnProductsWhenEmptyFileReceived()
        {
            // Arrange
            A.CallTo(() => mockFileHelper.ReadFileText(A <string> ._)).Returns(TestConstants.JsonFileText);
            A.CallTo(() => mockParser.Parse <ProductsObject>(A <string> ._)).Returns(GetProductObject());

            // Act
            softwareAdvice = new SoftwareAdvice(mockFileHelper);
            var output = softwareAdvice.ParseInput();

            // Assert
            A.CallTo(() => mockParser.Parse <ProductsObject>(A <string> ._)).MustHaveHappened();
            Assert.Equal(3, output.Products.Count);
        }
コード例 #2
0
        public void ShouldReturnZeroProductsWhenEmptyFileReceived()
        {
            // Arrange
            A.CallTo(() => mockFileHelper.ReadFileText(A <string> ._)).Returns(string.Empty);
            A.CallTo(() => mockParser.Parse <ProductsObject>(A <string> ._)).Returns(new ProductsObject());

            // Act
            softwareAdvice = new SoftwareAdvice(mockFileHelper);
            var output = softwareAdvice.ParseInput();

            // Assert
            A.CallTo(() => mockParser.Parse <ProductsObject>(A <string> ._)).MustHaveHappened();
            Assert.Null(output.Products);
        }