Example #1
0
        public void TestPaidMethod_ChangeFromCreatedToPaied()
        {
            // Arrange

            var suit                = GetSuitWithAlterationStatus(SuitAlterationStatus.Created);
            var stateFactory        = new SuitAlterationStateFactory();
            var suitAlterationState = SuitAlterationStateFactory.Create(suit);

            // Act
            suitAlterationState.Paid();

            // Asssert
            Assert.Equal(SuitAlterationStatus.Paid, suit.AlterationStatus);
        }
Example #2
0
        public void TestCreatedMethod_ChangeFromDefaultToCreated()
        {
            // Arrange

            var suit                = GetSuitWithAlterationStatus(SuitAlterationStatus.Default);
            var stateFactory        = new SuitAlterationStateFactory();
            var suitAlterationState = SuitAlterationStateFactory.Create(suit);

            // Act
            suitAlterationState.Created();

            // Asssert
            Assert.Equal(SuitAlterationStatus.Created, suit.AlterationStatus);
        }
Example #3
0
        public void TestDoneMethod_ThrowException_FromInLineData(SuitAlterationStatus currentState)
        {
            // Arrange

            var suit                = GetSuitWithAlterationStatus(currentState);
            var stateFactory        = new SuitAlterationStateFactory();
            var suitAlterationState = SuitAlterationStateFactory.Create(suit);
            var actualResult        = new Exception();

            // Act
            Action act = () => suitAlterationState.Done();

            // Asssert
            Assert.Throws <InvalidStateChangeException>(act);
        }
Example #4
0
 public void CreateAlteration(Alteration alteration)
 {
     if (alteration.HasData())
     {
         var validitor = DotNetCoreServiceLocator.Current.Resolve <IValidateAlterationService>();
         if (!validitor.HasAlteredBefore(Alteration) && validitor.IsAlterationMeasuresValid(Alteration))
         {
             Alteration = alteration;
             var currentState = SuitAlterationStateFactory.Create(this);
             currentState.Created();
             AlterationStatus = SuitAlterationStatus.Created;
         }
         else
         {
             throw new InvalidAlterationRequestException();
         }
     }
 }
Example #5
0
        public void Paid()
        {
            var currentState = SuitAlterationStateFactory.Create(this);

            currentState.Paid();
        }
Example #6
0
        public void AlterationIsDone()
        {
            var currentState = SuitAlterationStateFactory.Create(this);

            currentState.Done();
        }