public void CanParseReturnsExpectedResultWhenValueIsUnknown() { var value = _fixture.Create <string>(); var result = LifeCycleStageType.CanParse(value); Assert.False(result); }
public void CanParseReturnsExpectedResultWhenValueIsWellKnown() { var value = _knownValues[new Random().Next(0, _knownValues.Length)]; var result = LifeCycleStageType.CanParse(value); Assert.True(result); }
public void ToStringReturnsExpectedResult() { var value = _knownValues[new Random().Next(0, _knownValues.Length)]; var sut = LifeCycleStageType.Parse(value); var result = sut.ToString(); Assert.Equal(value, result); }
public void TryParseReturnsExpectedResultWhenValueIsUnknown() { var value = _fixture.Create <string>(); var result = LifeCycleStageType.TryParse(value, out var parsed); Assert.False(result); Assert.Null(parsed); }
public void TryParseReturnsExpectedResultWhenValueIsWellKnown() { var value = _knownValues[new Random().Next(0, _knownValues.Length)]; var result = LifeCycleStageType.TryParse(value, out var parsed); Assert.True(result); Assert.NotNull(parsed); Assert.Equal(value, parsed.ToString()); }
public AddStageToLifeCycle( PublicServiceId publicServiceId, LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod lifeCycleStagePeriod) { PublicServiceId = publicServiceId; LifeCycleStageType = lifeCycleStageType; LifeCycleStagePeriod = lifeCycleStagePeriod; }
public StageWasAddedToLifeCycle(PublicServiceId publicServiceId, LifeCycleStageId lifeCycleStageId, LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period) { PublicServiceId = publicServiceId; LifeCycleStageId = lifeCycleStageId; LifeCycleStageType = lifeCycleStageType; From = period.Start; To = period.End; }
public void WithValidData( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period) { Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered)) .When(new AddStageToLifeCycle(publicServiceId, lifeCycleStageType, period)) .Then(publicServiceId, new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(1), lifeCycleStageType, period))); }
public void CannotSetOnRemovedPublicService( PublicServiceId publicServiceId, PublicServiceName publicServiceName, ReasonForRemoval reasonForRemoval, LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period) { Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new PublicServiceWasRemoved(publicServiceId, reasonForRemoval)) .When(new AddStageToLifeCycle(publicServiceId, lifeCycleStageType, period)) .Throws(new CannotPerformActionOnRemovedPublicService())); }
public void AddStage(LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period) { if (_lifeCycleStagePeriods.Any(pair => pair.Value.OverlapsWith(period))) { throw new LifeCycleCannotHaveOverlappingPeriods(); } Apply( new StageWasAddedToLifeCycle( _publicServiceId, _lastUsedId.Next(), lifeCycleStageType, period)); }
public void WithValidData( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period, LifeCycleStageId lifeCycleStageLocalId) { Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new StageWasAddedToLifeCycle(publicServiceId, lifeCycleStageLocalId, lifeCycleStageType, period)) .When(new ChangePeriodOfLifeCycleStage(publicServiceId, lifeCycleStageLocalId, period)) .Then(publicServiceId, new PeriodOfLifeCycleStageWasChanged(publicServiceId, lifeCycleStageLocalId, period))); }
public void LifeCycleCannotHaveOverlappingPeriods( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStage1, LifeCycleStageType lifeCycleStage2) { var period1 = new LifeCycleStagePeriod(new ValidFrom(2018, LifeCycleStageId.FromNumber(1), 1), new ValidTo(2020, LifeCycleStageId.FromNumber(1), 1)); var period2 = new LifeCycleStagePeriod(new ValidFrom(2019, LifeCycleStageId.FromNumber(1), 1), new ValidTo(2021, LifeCycleStageId.FromNumber(1), 1)); Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(1), lifeCycleStage1, period1)) .When(new AddStageToLifeCycle(publicServiceId, lifeCycleStage2, period2)) .Throws(new LifeCycleCannotHaveOverlappingPeriods())); }
public void LifeCycleOverlapsTakesChangesIntoAccount( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStageType) { var period1 = new LifeCycleStagePeriod(new ValidFrom(2018, 1, 1), new ValidTo(2018, 1, 1)); var period2 = new LifeCycleStagePeriod(new ValidFrom(2020, 1, 2), new ValidTo(2022, 1, 1)); // Combining period2 with period3 will cause an overlap. var period3 = new LifeCycleStagePeriod(new ValidFrom(2019, 1, 1), new ValidTo(2021, 1, 1)); Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(1), lifeCycleStageType, period1), new PeriodOfLifeCycleStageWasChanged(publicServiceId, LifeCycleStageId.FromNumber(1), period2)) .When(new AddStageToLifeCycle(publicServiceId, lifeCycleStageType, period3)) .Throws(new LifeCycleCannotHaveOverlappingPeriods())); }
public void LifeCycleCannotHaveOverlappingPeriods( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStageType) { // These two periods are ok because they don't overlap var period1 = new LifeCycleStagePeriod(new ValidFrom(2018, 1, 1), new ValidTo(2020, 1, 1)); var period2 = new LifeCycleStagePeriod(new ValidFrom(2020, 1, 2), new ValidTo(2021, 1, 1)); // Combining period1 with period3 will cause an overlap, however. var period3 = new LifeCycleStagePeriod(new ValidFrom(2018, 1, 1), new ValidTo(2020, 1, 1)); Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(1), lifeCycleStageType, period1), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(2), lifeCycleStageType, period2)) .When(new ChangePeriodOfLifeCycleStage(publicServiceId, LifeCycleStageId.FromNumber(2), period3)) .Throws(new LifeCycleCannotHaveOverlappingPeriods())); }
public void LifeCycleStageDoesNotOverlapWhenChangingItsOwnPeriod( PublicServiceId publicServiceId, PublicServiceName publicServiceName, LifeCycleStageType lifeCycleStageType) { // These two periods are ok because they don't overlap var period1 = new LifeCycleStagePeriod(new ValidFrom(2018, 1, 1), new ValidTo(2020, 1, 1)); var period2 = new LifeCycleStagePeriod(new ValidFrom(2020, 1, 2), new ValidTo(2021, 1, 1)); // Changing period1 to period3 for '1' will not cause an overlap var period3 = new LifeCycleStagePeriod(new ValidFrom(2018, 1, 1), new ValidTo(2019, 1, 1)); Assert(new Scenario() .Given(publicServiceId, new PublicServiceWasRegistered(publicServiceId, publicServiceName, PrivateZoneId.Unregistered), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(1), lifeCycleStageType, period1), new StageWasAddedToLifeCycle(publicServiceId, LifeCycleStageId.FromNumber(2), lifeCycleStageType, period2)) .When(new ChangePeriodOfLifeCycleStage(publicServiceId, LifeCycleStageId.FromNumber(1), period3)) .Then(publicServiceId, new PeriodOfLifeCycleStageWasChanged(publicServiceId, LifeCycleStageId.FromNumber(1), period3))); }
public void ParseReturnsExpectedResultWhenValueIsWellKnown() { var value = _knownValues[new Random().Next(0, _knownValues.Length)]; Assert.NotNull(LifeCycleStageType.Parse(value)); }
public void ParseValueCanNotBeNull() { Assert.Throws <ArgumentNullException>(() => LifeCycleStageType.Parse(null)); }
public void ParseReturnsExpectedResultWhenValueIsUnknown() { var value = _fixture.Create <string>(); Assert.Throws <FormatException>(() => LifeCycleStageType.Parse(value)); }
public void AddStageToLifeCycle(LifeCycleStageType lifeCycleStageType, LifeCycleStagePeriod period) { EnsureNotRemoved(); _lifeCycle.AddStage(lifeCycleStageType, period); }