Esempio n. 1
0
        public static Alteration ToDomainModel(this AlterationViewModel alterationViewModel)
        {
            var rightShortenValue = new ShortenValue(alterationViewModel.RightShortenValue);
            var leftShortenValue  = new ShortenValue(alterationViewModel.LeftShortenValue);

            return(new Alteration(alterationViewModel.Id, alterationViewModel.CustomerId, alterationViewModel.SuitType, rightShortenValue, leftShortenValue));
        }
Esempio n. 2
0
        public void Create_With_Ammount_Between_Range_Must_Succeed(int ammount)
        {
            //Arrange
            var shortenValue = new ShortenValue(ammount);

            //Act
            var valid = shortenValue.IsValid();

            //Assert
            Assert.True(valid);
        }
Esempio n. 3
0
        public void Create_With_Ammount_Outside_Range_Must_Throws_DomainException(int ammount)
        {
            //Arrange
            var shortenValue = new ShortenValue(ammount);

            //Act
            var valid = shortenValue.IsValid();

            //Assert
            Assert.False(valid);
        }
Esempio n. 4
0
        public void Calling_MoveToNextStatus_Must_Change_Status_To_Paid()
        {
            //Arrange
            var rightShortenValue = new ShortenValue(0);
            var leftShortenValue  = new ShortenValue(0);
            var alteration        = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);

            //Act
            alteration.MoveToNextStatus();

            //Assert
            Assert.True(alteration.AlterationStatus == AlterationStatus.Paid);
        }
Esempio n. 5
0
        public void Create_Without_Input_Any_ShortenValue_Must_Be_False()
        {
            //Arrange
            var rightShortenValue = new ShortenValue(0);
            var leftShortenValue  = new ShortenValue(0);
            var alteration        = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);

            //Act
            var valid = alteration.IsValid();

            //Assert
            Assert.False(valid);
        }
Esempio n. 6
0
        public void Create_With_Valid_Inputs_ShortenValue_Must_Be_True()
        {
            //Arrange
            var rightShortenValue = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var leftShortenValue  = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var alteration        = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);

            //Act
            var valid = alteration.IsValid();

            //Assert
            Assert.True(valid);
        }
Esempio n. 7
0
        public void Calling_Done_Alteartion_MoveToNextStatus_Must_Add_Notiffication()
        {
            //Arrange
            var rightShortenValue = new ShortenValue(0);
            var leftShortenValue  = new ShortenValue(0);
            var alteration        = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);

            alteration.MoveToNextStatus();
            alteration.MoveToNextStatus();

            //Act
            alteration.MoveToNextStatus();

            //Assert
            Assert.True(alteration.GetNotifications().Count > 0);
        }
Esempio n. 8
0
        public void Invalid_Alteration_Updating_Must_Not_Call_Repository()
        {
            //Arrange
            var repository          = A.Fake <IAlterationRepository>();
            var notificationContext = A.Fake <INotificationContext>();
            var rightShortenValue   = new ShortenValue(Constants.INVALID_SHORTENVALUE);
            var leftShortenValue    = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var alteration          = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);
            var alterationService   = new AlterationService(repository, notificationContext);

            //Act
            var ret = alterationService.CreateAlterationAsync(alteration);

            //Assert
            A.CallTo(() => repository.UpdateAsync(alteration)).MustNotHaveHappened();
        }
Esempio n. 9
0
        public void Order_Alteration_Succesfully_Calling_Repository_MustSucceed()
        {
            //Arrange
            var repository          = A.Fake <IAlterationRepository>();
            var notificationContext = A.Fake <INotificationContext>();
            var rightShortenValue   = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var leftShortenValue    = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var alteration          = new Alteration(Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);
            var alterationService   = new AlterationService(repository, notificationContext);

            //Act
            var ret = alterationService.CreateAlterationAsync(alteration);

            //Assert
            Assert.NotNull(ret);
        }
Esempio n. 10
0
        public async void Order_Done_MovingToNextstatus_Must_Throws_Exception()
        {
            //Arrange
            var repository          = A.Fake <IAlterationRepository>();
            var notificationContext = A.Fake <INotificationContext>();
            var rightShortenValue   = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var leftShortenValue    = new ShortenValue(Constants.VALID_SHORTENVALUE);
            var alteration          = new Alteration(Guid.Parse(Constants.VALID_GUIDVALUE), Constants.VALID_CUSTOMERID, SuitType.Jacket, rightShortenValue, leftShortenValue);

            alteration.MoveToNextStatus();
            alteration.MoveToNextStatus();
            A.CallTo(() => repository.GetAsync(Guid.Parse(Constants.VALID_GUIDVALUE))).Returns(alteration);
            var alterationService = new AlterationService(repository, notificationContext);

            //Act & Assert
            await Assert.ThrowsAsync <DomainException>(async() => await alterationService.MoveToTheNextStatusAsync(alteration.Id));
        }