public void Build_ShouldSetIsValidToFalseWhenIdOrNameNotSet(InputLineModelBuilder sut)
        {
            // arrange
            sut.Build();

            // act
            var actual = sut.IsValid;

            // assert
            actual.ShouldBeFalse();
        }
        public void BuildName_ShouldSetNameFieldFromProductNameToken([Frozen] Mock <ITokenizer> tokenizerMock,
                                                                     InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(Token.ProductName);

            // act
            sut.BuildId(tokenizerMock.Object);

            // assert
            sut.Build().Name.ShouldBe(tokenizerMock.Object.Value);
        }
        public void BuildComment_ShouldSetIsCommentToFalseForNonCommentLine(
            Token token, [Frozen] Mock <ITokenizer> tokenizerMock, InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(token);

            // act
            sut.BuildComment(tokenizerMock.Object);

            // assert
            sut.IsComment.ShouldBeFalse();
        }
        public void Quantities_ShouldNotSetQuantitiesFieldFromNonWarehouseInfoToken(
            Token token, [Frozen] Mock <ITokenizer> tokenizerMock, InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(token);

            // act
            sut.BuildId(tokenizerMock.Object);

            // assert
            sut.Build().Quantities.ShouldBeEmpty();
        }
        public void BuildName_ShouldNotSetNameFieldFromNonProductIdToken(
            Token token, [Frozen] Mock <ITokenizer> tokenizerMock, InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(token);

            // act
            sut.BuildId(tokenizerMock.Object);

            // assert
            sut.Build().Name.ShouldBeNull();
        }
        public void BuildQuantities_ShouldThrowExceptionWhenUnableToParseToken(
            string warehouseInfo, [Frozen] Mock <ITokenizer> tokenizerMock, InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(Token.WarehouseInfo);
            tokenizerMock.Setup(m => m.Value).Returns(warehouseInfo);

            // act
            var actual = Record.Exception(() => sut.BuildQuantities(tokenizerMock.Object));

            // assert
            actual.ShouldNotBeNull();
            actual.ShouldBeOfType <InputLineParsingException>();
        }
        public void BuildQuantities_ShouldSetQuantitiesFieldWarehouseInfoToken(
            string warehouseInfo, [Frozen] Mock <ITokenizer> tokenizerMock, InputLineModelBuilder sut)
        {
            // arrange
            tokenizerMock.Setup(m => m.Token).Returns(Token.WarehouseInfo);
            tokenizerMock.Setup(m => m.Value).Returns(warehouseInfo);

            // act
            sut.BuildQuantities(tokenizerMock.Object);

            // assert
            var quantities = sut.Build().Quantities;

            quantities.Count().ShouldBe(2);
            quantities.ShouldContain(q => "WH-A".Equals(q.WarehouseName) && q.Quantity == 12);
            quantities.ShouldContain(q => "WH-B".Equals(q.WarehouseName) && q.Quantity == 3);
        }
        public void Build_ShouldSetIsValidToTrueWhenIdAndNameBothSet(Mock <ITokenizer> idTokenizerMock, string name,
                                                                     Mock <ITokenizer> nameTokenizerMock, string id,
                                                                     InputLineModelBuilder sut)
        {
            // arrange
            idTokenizerMock.Setup(m => m.Token).Returns(Token.ProductId);
            idTokenizerMock.Setup(m => m.Value).Returns(name);
            sut.BuildId(idTokenizerMock.Object);

            nameTokenizerMock.Setup(m => m.Token).Returns(Token.ProductName);
            nameTokenizerMock.Setup(m => m.Value).Returns(id);
            sut.BuildName(nameTokenizerMock.Object);

            sut.Build();

            // act
            var actual = sut.IsValid;

            // assert
            actual.ShouldBeTrue();
        }