Ejemplo n.º 1
0
        public async Task siteSurveyConfiguration_Delete_DoesDelete()
        {
            // Arrange
            Random rnd = new Random();

            question_sets questionSet = new question_sets()
            {
                ParentId = 0
            };

            await questionSet.Create(dbContext).ConfigureAwait(false);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                Name          = Guid.NewGuid().ToString(),
                Stop          = DateTime.Now,
                Start         = DateTime.Now,
                TimeOut       = rnd.Next(1, 255),
                TimeToLive    = rnd.Next(1, 255),
                QuestionSetId = questionSet.Id
            };

            await surveyConfiguration.Create(dbContext).ConfigureAwait(false);

            sites site1 = await testHelpers.CreateSite("SiteName1", 88);

            site_survey_configurations siteSurveyConfiguration = new site_survey_configurations
            {
                SiteId = site1.Id,
                SurveyConfigurationId = surveyConfiguration.Id
            };
            await siteSurveyConfiguration.Create(dbContext).ConfigureAwait(false);

            // Act
            await siteSurveyConfiguration.Delete(dbContext);

            site_survey_configurations dbSiteSurveyConfiguration =
                dbContext.site_survey_configurations.AsNoTracking().First();
            site_survey_configuration_versions dbSiteSurveyConfigurationVersion =
                dbContext.site_survey_configuration_versions.AsNoTracking().First();

            // Assert
            Assert.NotNull(dbSiteSurveyConfiguration);
            Assert.NotNull(dbSiteSurveyConfigurationVersion);

            Assert.AreEqual(site1.Id, dbSiteSurveyConfiguration.SiteId);
            Assert.AreEqual(surveyConfiguration.Id, siteSurveyConfiguration.SurveyConfigurationId);
            Assert.AreEqual(Constants.WorkflowStates.Removed, siteSurveyConfiguration.WorkflowState);
        }
Ejemplo n.º 2
0
        public async Task SiteSurveyConfiguration_Delete_DoesDelete()
        {
            //Arrange

            Random rnd = new Random();

            sites site = new sites
            {
                Name         = Guid.NewGuid().ToString(),
                MicrotingUid = rnd.Next(1, 255)
            };
            await site.Create(dbContext).ConfigureAwait(false);

            question_sets questionSet = new question_sets()
            {
                ParentId = 0
            };

            await questionSet.Create(dbContext).ConfigureAwait(false);

            survey_configurations surveyConfiguration = new survey_configurations
            {
                Name          = Guid.NewGuid().ToString(),
                Start         = DateTime.Now,
                Stop          = DateTime.Now,
                TimeOut       = rnd.Next(1, 255),
                TimeToLive    = rnd.Next(1, 255),
                QuestionSetId = questionSet.Id
            };
            await surveyConfiguration.Create(dbContext).ConfigureAwait(false);

            site_survey_configurations siteSurveyConfiguration = new site_survey_configurations
            {
                SiteId = site.Id,
                SurveyConfigurationId = surveyConfiguration.Id
            };
            await siteSurveyConfiguration.Create(dbContext).ConfigureAwait(false);

            //Act

            DateTime?oldUpdatedAt = siteSurveyConfiguration.UpdatedAt;

            await siteSurveyConfiguration.Delete(dbContext);


            List <site_survey_configurations>         siteSurveyConfigurations        = dbContext.site_survey_configurations.AsNoTracking().ToList();
            List <site_survey_configuration_versions> siteSurveyConfigurationVersions = dbContext.site_survey_configuration_versions.AsNoTracking().ToList();

            Assert.NotNull(siteSurveyConfigurations);
            Assert.NotNull(siteSurveyConfigurationVersions);

            Assert.AreEqual(1, siteSurveyConfigurations.Count());
            Assert.AreEqual(2, siteSurveyConfigurationVersions.Count());

            Assert.AreEqual(siteSurveyConfiguration.CreatedAt.ToString(), siteSurveyConfigurations[0].CreatedAt.ToString());
            Assert.AreEqual(siteSurveyConfiguration.Version, siteSurveyConfigurations[0].Version);
//            Assert.AreEqual(siteSurveyConfiguration.UpdatedAt.ToString(), siteSurveyConfigurations[0].UpdatedAt.ToString());
            Assert.AreEqual(siteSurveyConfigurations[0].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(siteSurveyConfiguration.Id, siteSurveyConfigurations[0].Id);
            Assert.AreEqual(siteSurveyConfiguration.SiteId, site.Id);
            Assert.AreEqual(siteSurveyConfiguration.SurveyConfigurationId, surveyConfiguration.Id);

            //Old Version

            Assert.AreEqual(siteSurveyConfiguration.CreatedAt.ToString(), siteSurveyConfigurationVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, siteSurveyConfigurationVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), siteSurveyConfigurationVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(siteSurveyConfigurationVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(siteSurveyConfiguration.Id, siteSurveyConfigurationVersions[0].SiteSurveyConfigurationId);
            Assert.AreEqual(site.Id, siteSurveyConfigurationVersions[0].SiteId);
            Assert.AreEqual(surveyConfiguration.Id, siteSurveyConfigurationVersions[0].SurveyConfigurationId);

            //New Version

            Assert.AreEqual(siteSurveyConfiguration.CreatedAt.ToString(), siteSurveyConfigurationVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, siteSurveyConfigurationVersions[1].Version);
//            Assert.AreEqual(siteSurveyConfiguration.UpdatedAt.ToString(), siteSurveyConfigurationVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(siteSurveyConfigurationVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(siteSurveyConfiguration.Id, siteSurveyConfigurationVersions[1].SiteSurveyConfigurationId);
            Assert.AreEqual(site.Id, siteSurveyConfigurationVersions[1].SiteId);
            Assert.AreEqual(surveyConfiguration.Id, siteSurveyConfigurationVersions[1].SurveyConfigurationId);
        }