Ejemplo n.º 1
0
        public void BeginNewScenario_sets_all_scenario_and_feature_properties(Guid scenarioIdentity,
                                                                              IFormatsObjectForReport formatter,
                                                                              IBuildsScenario scenarioBuilder,
                                                                              Builders.IGetsReport reportFactory,
                                                                              string scenarioId,
                                                                              string scenarioName,
                                                                              string featureId,
                                                                              string featureName,
                                                                              bool scenarioIdGenerated,
                                                                              bool featureIdGenerated)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            // Act
            sut.BeginNewScenario(scenarioId,
                                 scenarioName,
                                 featureName,
                                 featureId,
                                 scenarioIdentity,
                                 scenarioIdGenerated,
                                 featureIdGenerated);

            // Assert
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioIdName        = scenarioId, Times.Once, nameof(IBuildsScenario.ScenarioIdName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioFriendlyName  = scenarioName, Times.Once, nameof(IBuildsScenario.ScenarioFriendlyName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureIdName         = featureId, Times.Once, nameof(IBuildsScenario.FeatureIdName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureFriendlyName   = featureName, Times.Once, nameof(IBuildsScenario.FeatureFriendlyName));
            Mock.Get(scenarioBuilder).VerifySet(x => x.ScenarioIdIsGenerated = scenarioIdGenerated, Times.Once, nameof(IBuildsScenario.ScenarioIdIsGenerated));
            Mock.Get(scenarioBuilder).VerifySet(x => x.FeatureIdIsGenerated  = featureIdGenerated, Times.Once, nameof(IBuildsScenario.FeatureIdIsGenerated));
        }
Ejemplo n.º 2
0
        public void EndPerformanceType_calls_EndPerformanceType_from_builder(IBuildsScenario scenarioBuilder,
                                                                             IFormatsObjectForReport formatter,
                                                                             Builders.IGetsReport reportFactory,
                                                                             Guid scenarioIdentity)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);

            // Act
            sut.EndPerformanceCategory(scenarioIdentity);

            // Assert
            Mock.Get(scenarioBuilder).Verify(x => x.EndPerformanceCategory(), Times.Once);
        }
Ejemplo n.º 3
0
        public void EndScenario_calls_finalise_for_the_appropriate_builder(IBuildsScenario scenarioBuilder,
                                                                           IFormatsObjectForReport formatter,
                                                                           Builders.IGetsReport reportFactory,
                                                                           bool success,
                                                                           Guid scenarioIdentity)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);

            // Act
            sut.EndScenario(success, scenarioIdentity);

            // Assert
            Mock.Get(scenarioBuilder).Verify(x => x.Finalise(success), Times.Once);
        }
Ejemplo n.º 4
0
        public void GetReport_returns_result_from_factory(IBuildsScenario scenarioBuilder,
                                                          IFormatsObjectForReport formatter,
                                                          Builders.IGetsReport reportFactory,
                                                          Report report)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            Mock.Get(reportFactory)
            .Setup(x => x.GetReport(It.IsAny <IEnumerable <IBuildsScenario> >()))
            .Returns(report);

            // Act
            var result = sut.GetReport();

            // Assert
            Assert.That(result, Is.SameAs(report));
        }
Ejemplo n.º 5
0
        public void GainAbility_calls_GainAbility_from_builder(IBuildsScenario scenarioBuilder,
                                                               IFormatsObjectForReport formatter,
                                                               Builders.IGetsReport reportFactory,
                                                               INamed actor,
                                                               IAbility ability,
                                                               Guid scenarioIdentity)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);

            // Act
            sut.GainAbility(actor, ability, scenarioIdentity);

            // Assert
            Mock.Get(scenarioBuilder).Verify(x => x.GainAbility(actor, ability), Times.Once);
        }
Ejemplo n.º 6
0
        public void RecordSuccess_calls_RecordSuccess_from_builder(IBuildsScenario scenarioBuilder,
                                                                   IFormatsObjectForReport formatter,
                                                                   Builders.IGetsReport reportFactory,
                                                                   IActor actor,
                                                                   IPerformable performable,
                                                                   Guid scenarioIdentity)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);
            sut.BeginPerformance(actor, performable, scenarioIdentity);

            // Act
            sut.RecordSuccess(performable, scenarioIdentity);

            // Assert
            Mock.Get(scenarioBuilder).Verify(x => x.RecordSuccess(performable), Times.Once);
        }
Ejemplo n.º 7
0
        public void GetReport_passes_same_number_of_builders_as_scenarios(IBuildsScenario scenarioBuilder,
                                                                          IFormatsObjectForReport formatter,
                                                                          Builders.IGetsReport reportFactory,
                                                                          [Values(1, 2, 5, 10)] int howManyScenarios)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            foreach (var iterations in Enumerable.Range(0, howManyScenarios))
            {
                sut.BeginNewScenario(null, null, null, null, Guid.NewGuid(), false, false);
            }

            // Act
            sut.GetReport();

            // Assert
            Mock.Get(reportFactory)
            .Verify(x => x.GetReport(It.Is <IEnumerable <IBuildsScenario> >(b => b.Count() == howManyScenarios)), Times.Once());
        }
Ejemplo n.º 8
0
        public void GetReport_passes_builder_created_from_scenario_factory_to_report_factory(IBuildsScenario scenarioBuilder,
                                                                                             IFormatsObjectForReport formatter,
                                                                                             Builders.IGetsReport reportFactory,
                                                                                             Guid scenarioIdentity)
        {
            // Arrange
            var sut = new ReportBuilder(formatter, reportFactory, GetScenarioBuilderFactory(scenarioBuilder));

            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);

            // Act
            sut.GetReport();

            // Assert
            Mock.Get(reportFactory)
            .Verify(x => x.GetReport(It.Is <IEnumerable <IBuildsScenario> >(b => b.Contains(scenarioBuilder))), Times.Once());
        }
Ejemplo n.º 9
0
        public void BeginNewScenario_uses_factory_to_create_a_scenario_using_the_scenario_identity(Guid scenarioIdentity,
                                                                                                   IFormatsObjectForReport formatter,
                                                                                                   IBuildsScenario scenarioBuilder,
                                                                                                   Builders.IGetsReport reportFactory)
        {
            // Arrange
            Guid capturedGuid = Guid.Empty;
            Func <Guid, IFormatsObjectForReport, IBuildsScenario> scenarioBuilderFactory = (g, f) => {
                capturedGuid = g;
                return(scenarioBuilder);
            };
            var sut = new ReportBuilder(formatter, reportFactory, scenarioBuilderFactory);

            // Act
            sut.BeginNewScenario(null, null, null, null, scenarioIdentity, false, false);

            // Assert
            Assert.That(capturedGuid, Is.EqualTo(scenarioIdentity));
        }