コード例 #1
0
        public async Task questionSet_Delete_DoesDelete_HasChildAndPosiblyDeployedTrue()
        {
            // Arrange
            string name = Guid.NewGuid().ToString();

            question_sets questionSet = new question_sets
            {
                Name = name, Share = false, HasChild = false, PosiblyDeployed = false
            };

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

            // Act
            questionSet.Name            = name;
            questionSet.Share           = false;
            questionSet.HasChild        = true;
            questionSet.PosiblyDeployed = true;

            await questionSet.Delete(dbContext);

            question_sets         dbQuestionSet        = dbContext.question_sets.AsNoTracking().First();
            question_set_versions dbQuestionSetVersion = dbContext.question_set_versions.AsNoTracking().First();

            // Assert
            Assert.NotNull(dbQuestionSet);
            Assert.NotNull(dbQuestionSetVersion);

            Assert.AreEqual(questionSet.Name, dbQuestionSet.Name);
            Assert.AreEqual(false, dbQuestionSet.Share);
            Assert.AreEqual(true, dbQuestionSet.HasChild);
            Assert.AreEqual(true, dbQuestionSet.PosiblyDeployed);
            Assert.AreEqual(2, dbQuestionSet.Version);
            Assert.AreEqual(dbQuestionSet.WorkflowState, Constants.WorkflowStates.Removed);
        }
コード例 #2
0
        public async Task QuestionSets_Delete_DoesSetWorkflowStateToRemoved()
        {
            //Arrange

            Random rnd        = new Random();
            bool   randomBool = rnd.Next(0, 2) > 0;

            question_sets questionSet = new question_sets
            {
                Name            = Guid.NewGuid().ToString(),
                Share           = randomBool,
                HasChild        = randomBool,
                PosiblyDeployed = randomBool
            };
            await questionSet.Create(dbContext).ConfigureAwait(false);

            //Act

            DateTime?oldUpdatedAt = questionSet.UpdatedAt;

            await questionSet.Delete(dbContext);

            List <question_sets>         questionSets        = dbContext.question_sets.AsNoTracking().ToList();
            List <question_set_versions> questionSetVersions = dbContext.question_set_versions.AsNoTracking().ToList();

            Assert.NotNull(questionSets);
            Assert.NotNull(questionSetVersions);

            Assert.AreEqual(1, questionSets.Count());
            Assert.AreEqual(2, questionSetVersions.Count());

            Assert.AreEqual(questionSet.CreatedAt.ToString(), questionSets[0].CreatedAt.ToString());
            Assert.AreEqual(questionSet.Version, questionSets[0].Version);
//            Assert.AreEqual(questionSet.UpdatedAt.ToString(), questionSets[0].UpdatedAt.ToString());
            Assert.AreEqual(questionSets[0].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(questionSet.Id, questionSets[0].Id);
            Assert.AreEqual(questionSet.Name, questionSets[0].Name);
            Assert.AreEqual(questionSet.Share, questionSets[0].Share);
            Assert.AreEqual(questionSet.HasChild, questionSets[0].HasChild);
            Assert.AreEqual(questionSet.PosiblyDeployed, questionSets[0].PosiblyDeployed);

            //Old Version

            Assert.AreEqual(questionSet.CreatedAt.ToString(), questionSetVersions[0].CreatedAt.ToString());
            Assert.AreEqual(1, questionSetVersions[0].Version);
//            Assert.AreEqual(oldUpdatedAt.ToString(), questionSetVersions[0].UpdatedAt.ToString());
            Assert.AreEqual(questionSetVersions[0].WorkflowState, Constants.WorkflowStates.Created);
            Assert.AreEqual(questionSet.Id, questionSetVersions[0].QuestionSetId);
            Assert.AreEqual(questionSet.Name, questionSetVersions[0].Name);
            Assert.AreEqual(questionSet.Share, questionSetVersions[0].Share);
            Assert.AreEqual(questionSet.HasChild, questionSetVersions[0].HasChild);
            Assert.AreEqual(questionSet.PosiblyDeployed, questionSetVersions[0].PossiblyDeployed);

            //New Version
            Assert.AreEqual(questionSet.CreatedAt.ToString(), questionSetVersions[1].CreatedAt.ToString());
            Assert.AreEqual(2, questionSetVersions[1].Version);
//            Assert.AreEqual(questionSet.UpdatedAt.ToString(), questionSetVersions[1].UpdatedAt.ToString());
            Assert.AreEqual(questionSetVersions[1].WorkflowState, Constants.WorkflowStates.Removed);
            Assert.AreEqual(questionSet.Id, questionSetVersions[1].QuestionSetId);
            Assert.AreEqual(questionSet.Name, questionSetVersions[1].Name);
            Assert.AreEqual(questionSet.Share, questionSetVersions[1].Share);
            Assert.AreEqual(questionSet.HasChild, questionSetVersions[1].HasChild);
            Assert.AreEqual(questionSet.PosiblyDeployed, questionSetVersions[1].PossiblyDeployed);
        }