示例#1
0
        public void Map_ThrowsInconclusiveException_PipeIsInErrorStateWithInconclusive(bool isAsync)
        {
            const string initalValue   = "initial-value";
            const string scenarioTitle = "scenario-title";
            const string givenStepText = "given-step";

            Pipe <string> pipe = new Ctn <string>(initalValue, new[]
            {
                new StepOutcome(Step.Given, Outcome.Pass, givenStepText)
            }, scenarioTitle);

            Pipe <int> result;

            if (isAsync)
            {
                result = pipe.Map(PipeMapFunctions.MapAsyncRaiseInconclusiveEx());
            }
            else
            {
                result = pipe.Map(PipeMapFunctions.MapSyncRaiseInconclusiveEx());
            }

            result.ShouldBeError(ctnError =>
            {
                ctnError.ScenarioTitle.ShouldBeSome(title => title.Should().Be(scenarioTitle));
                ctnError.Content.Should().NotBeNull();
                ctnError.Content.SourceException.Should().NotBeNull();
                ctnError.Content.SourceException.Should().BeOfType <InconclusiveException>();
                ctnError.StepOutcomes.ShouldHaveSingleStepOutcome(Outcome.Inconclusive, givenStepText, Step.Given);
            });
        }
示例#2
0
        public void Map_FunctionToValueOfSameType_MapsCorrectly()
        {
            var ctnWithValueOnly = new Ctn <int>(DefaultValue, None);
            var newCtn           = ctnWithValueOnly.Map(currentValue => currentValue + 1);

            newCtn.Should().NotBeNull();
            newCtn.Content.Should().Be(DefaultValue + 1);
            newCtn.ScenarioTitle.ShouldBeNone();
            newCtn.StepOutcomes.Should().NotBeNull();
            newCtn.StepOutcomes.Count.Should().Be(0);
        }
示例#3
0
        public void Map_FromCtnWithNoStepOutcomes_MapsToNewCtnType()
        {
            var ctnWithValueOnly = new Ctn <int>(DefaultValue, None);
            var newCtn           = ctnWithValueOnly.Map(currentValue => currentValue.ToString());

            newCtn.Should().NotBeNull();
            newCtn.Content.Should().Be(DefaultValue.ToString());
            newCtn.ScenarioTitle.ShouldBeNone();
            newCtn.StepOutcomes.Should().NotBeNull();
            newCtn.StepOutcomes.Count.Should().Be(0);
        }
示例#4
0
        public void Map_ToNull_MapsToNewCtnType()
        {
            var ctnWithValueOnly = new Ctn <string>("initial value", None);

            const string newValue = null;
            var          newCtn   = ctnWithValueOnly.Map(currentValue => newValue);

            newCtn.Should().NotBeNull();
            newCtn.Content.Should().Be(newValue);
            newCtn.ScenarioTitle.ShouldBeNone();
            newCtn.StepOutcomes.Should().NotBeNull();
            newCtn.StepOutcomes.Count.Should().Be(0);
        }
示例#5
0
        public void Map_FromNull_MapsToNewCtnType()
        {
            var ctnWithValueOnly = new Ctn <string>(null, None);

            decimal newValue = 12.45m;
            var     newCtn   = ctnWithValueOnly.Map(currentValue => newValue);

            newCtn.Should().NotBeNull();
            newCtn.Content.Should().Be(newValue);
            newCtn.ScenarioTitle.ShouldBeNone();
            newCtn.StepOutcomes.Should().NotBeNull();
            newCtn.StepOutcomes.Count.Should().Be(0);
        }
示例#6
0
        public void Map_AsyncOverload_MapsToCtnOfNewValue()
        {
            const string initalValue   = "initial-value";
            const string scenarioTitle = "scenario-title";
            const string givenStepText = "given-step";

            Pipe <string> pipe = new Ctn <string>(initalValue, new[]
            {
                new StepOutcome(Step.Given, Outcome.Pass, givenStepText)
            }, scenarioTitle);

            var result = pipe.Map(async value =>
            {
                await Task.Delay(10);
                return(new DateTime(2000, 1, 1, 1, 1, 1));
            });

            result.ShouldBeSuccessful(ctnValue =>
            {
                ctnValue.ScenarioTitle.ShouldBeSome(title => title.Should().Be(scenarioTitle));
                ctnValue.Content.Should().Be(new DateTime(2000, 1, 1, 1, 1, 1));
                ctnValue.StepOutcomes.ShouldHaveSingleStepOutcome(Outcome.Pass, givenStepText, Step.Given);
            });
        }