Пример #1
0
        public DiamondViewModel Build()
        {
            var diamond = diamondRepository.GetDiamondByID(customJewelPersistence.DiamondID);
            //stage one we map
            var viewModel = mapper.Map <Diamond, DiamondViewModel>(diamond);

            //stage 2 we add things that we don't want to map
            viewModel.TabsForJewelDesignNavigation = tabsForJewelDesignNavigationBuilder.Build();

            viewModel.JewelPersistence = customJewelPersistence;

            viewModel.DiamondHelp = diamondHelpBuilder.Build(diamond);

            return(viewModel);
        }
        public void Build_ReturnTheRightTitleForColorAsAnExmpleForAllOtherAsItsTheSameAlgorithm()
        {
            //Arrange
            var diamond = new Diamond()
            {
                Color   = "H",
                Clarity = "VVS1",
                Cut     = "VG"
            };

            var xmlSourceFactory = new FakeXmlSourceFactory();

            var builder = new DiamondHelpBuilder(xmlSourceFactory);
            //Act
            var list = builder.Build(diamond);

            //Assert
            list["color"].Title.Should().Be("Color");
        }
        public void Build_ShouldReturnThreeHelpItems()
        {
            //Arrange
            var diamond = new Diamond()
            {
                Color   = "H",
                Clarity = "VVS1",
                Cut     = "VG"
            };

            var xmlSourceFactory = new FakeXmlSourceFactory();

            var builder = new DiamondHelpBuilder(xmlSourceFactory);
            //Act
            var list = builder.Build(diamond);

            //Assert
            list.Should().HaveCount(3);
        }
        public void Build_ReturnNAForTheBodyTextWhenTheXmlDoesntContainTheDefinition()
        {
            //Arrange
            var diamond = new Diamond()
            {
                Color   = "P",
                Clarity = "VVS1",
                Cut     = "VG"
            };

            var xmlSourceFactory = new FakeXmlSourceFactory();

            var builder = new DiamondHelpBuilder(xmlSourceFactory);
            //Act
            var list = builder.Build(diamond);

            //Assert
            list["color"].BodyText.Should().Be("N/A");
        }
        public void Build_ReturnTheAllTheValuesForColorAsAnExmpleForAllOtherAsItsTheSameAlgorithm()
        {
            //Arrange
            var diamond = new Diamond()
            {
                Color   = "H",
                Clarity = "VVS1",
                Cut     = "VG"
            };

            var xmlSourceFactory = new FakeXmlSourceFactory();

            var builder = new DiamondHelpBuilder(xmlSourceFactory);
            //Act
            var list = builder.Build(diamond);

            //Assert
            list["color"].HelpValues.Should().Contain("E");
            list["color"].HelpValues.Should().Contain("F");
            list["color"].HelpValues.Should().Contain("G");
            list["color"].HelpValues.Should().Contain("H");
        }