예제 #1
0
        public void When_ActiveCampaign_UpdatingRestrictedFields_ConditionValidationServiceReturnsInvalidResponse_Expect_InvalidResponse()
        {
            // Arrange
            var fixture = new CampaignValidationServiceTestFixture(CampaignStatus.Active)
            {
                DbCampaign =
                {
                    Reward = 3.0m
                },
                Campaign =
                {
                    Reward = 4.0m
                }
            };

            fixture.SetupConditionValidationServiceMockValidateConditionsAreNotChangedReturnsInvalidResult();
            fixture.SetupConditionValidationServiceMockValidateConditionsPartnersReturnsInvalidResult();

            var campaignValidationService = new CampaignValidationService(fixture.ConditionValidationServiceMock.Object,
                                                                          fixture.EarnRuleContentValidationService.Object);
            // Act
            var validationResult = campaignValidationService.ValidateUpdate(fixture.Campaign, fixture.DbCampaign);

            // Assert
            Assert.False(validationResult.IsValid);
            Assert.Single(validationResult.ValidationMessages);
        }
예제 #2
0
        public void When_ActiveCampaign_UpdatingNotRestrictedFields_ConditionValidationServiceReturnsValidResponse_Expect_ValidResponse()
        {
            // Arrange
            var fixture = new CampaignValidationServiceTestFixture(CampaignStatus.Active)
            {
                DbCampaign =
                {
                    Name        = "dbCampaign",
                    Description = "dbCampaign"
                },
                Campaign =
                {
                    Name        = "campaign",
                    Description = "campaign",
                    IsEnabled   = false,
                    FromDate    = DateTime.UtcNow.AddDays(-3),
                    ToDate      = DateTime.UtcNow.AddDays(-1)
                }
            };

            fixture.SetupConditionValidationServiceMockValidateConditionsAreNotChangedReturnsValidResult();
            fixture.SetupConditionValidationServiceMockValidateConditionsPartnersReturnsValidResult();

            var campaignValidationService = new CampaignValidationService(fixture.ConditionValidationServiceMock.Object,
                                                                          fixture.EarnRuleContentValidationService.Object);
            // Act
            var validationResult = campaignValidationService.ValidateUpdate(fixture.Campaign, fixture.DbCampaign);

            // Assert
            Assert.True(validationResult.IsValid);
            Assert.Empty(validationResult.ValidationMessages);
        }
예제 #3
0
        public void When_CompletedCampaign_NoFieldsUpdated_ConditionValidationServiceReturnsValidResponse_Expect_ValidResponse()
        {
            // Arrange
            var fixture = new CampaignValidationServiceTestFixture(CampaignStatus.Completed);

            fixture.SetupConditionValidationServiceMockValidateConditionsAreNotChangedReturnsValidResult();
            fixture.SetupConditionValidationServiceMockValidateConditionsPartnersReturnsValidResult();

            var campaignValidationService = new CampaignValidationService(fixture.ConditionValidationServiceMock.Object,
                                                                          fixture.EarnRuleContentValidationService.Object);
            // Act
            var validationResult = campaignValidationService.ValidateUpdate(fixture.Campaign, fixture.DbCampaign);

            // Assert
            Assert.True(validationResult.IsValid);
            Assert.Empty(validationResult.ValidationMessages);
        }